pyjack
======

pyjack is a small debug / test module that allows you to: 

* Connect a 'spy' function to almost any python function.  This spy function
  is called instead of the original function.  The original function is passed
  to the spy function along with all args, kwargs so you can call the original
  function; modify the args, kwargs first, print a debug message, then call it; 
  not call the function, just log it or print a debug message; etc. etc.   
  
* Provides a convenience function pyjack.replace_all_refs which uses the gc
  module to replace all references to an object with references to another 
  object. 

A quick example::

    >>> import pyjack
    >>> 
    >>> def fakeimport(orgopen, *args, **kwargs):
    ...     
    ...     print 'Trying to import %s' % args[0]
    ...     
    ...     return 'MODULE_%s' % args[0]
    ... 
    >>>
    >>>
    >>> pyjack.connect(__import__, spyfn=fakeimport)
    <..._PyjackFuncBuiltin object at 0x...>
    >>> 
    >>>
    >>> import time
    Trying to import time
    >>>
    >>>
    >>> print time
    MODULE_time
    >>> 
    >>>
    >>> __import__.restore()
    >>> 
    >>> import time
    >>> print time
    <module 'time' (built-in)>

    
For full documentation and several examples please visit 
http://packages.python.org/pyjack/.

The git repo is here: https://github.com/cart0113/pyjack 
 
 
