Lesson 6

Let's say you want to do some quick debugging of a Subversion-facing application, but you don't want to mock up the entire session? svnmock comes equipped with facilities to observe what API functions are being called, with what arguments and what values they return. Your program continues to run normally, svnmock simply watches what happens.

Without further ado, svnmock.trace.

svnmock.trace is probably the easiest part of svnmock to explain:

from svnmock import trace
import my_svn_facing_library

my_svn_facing_library.frobnicate()

# ...
# more frobnication and foo_bar_baz-ery
# ...

trace.pretty_print()

svnmock will sit between your code and Subversion, watching what happens. The call to trace.pretty_print() will print a list of API calls to the process's standard out. The listing looks something like this:

000: apr_initialize
     +-> Args: ()
     +-> Returned: 0

001: svn_pool_create
     +-> Args: (None,)
     +-> Returned: _70891308_p_apr_pool_t

002: svn_pool_create
     +-> Args: (<Swig Object at _70891308_p_apr_pool_t>,)
     +-> Returned: _78a91308_p_apr_pool_t

In case you want to skip over some calls you're not interested in, svnmock.trace.pretty_print() includes a start keyword parameter. This allows you to specify which call you'd like to start printing at (calls are zero-indexed). Also, a limit keyword parameter allows you to print a certain number of calls, then stop.

svnmock