testing.decorator_msim — IPython v0.10 documentation

### Navigation

- index
- modules |
- next |
- previous |
- IPython v0.10 documentation »
- The IPython API »

# testing.decorator_msim

## Module: `testing.decorator_msim`

## Functions

`IPython.testing.decorator_msim.` `decorator`(caller, func=None)

  General purpose decorator factory: takes a caller function as input and returns a decorator with the same attributes. A caller function is any function like this:

      def caller(func, *args, **kw):
          # do something
          return func(*args, **kw)

  Here is an example of usage:

      >>> @decorator
      ... def chatty(f, *args, **kw):
      ...     print "Calling %r" % f.__name__
      ...     return f(*args, **kw)

      >>> chatty.__name__
      'chatty'

      >>> @chatty
      ... def f(): pass
      ...
      >>> f()
      Calling 'f'

  For sake of convenience, the decorator factory can also be called with two arguments. In this casem `decorator(caller, func)` is just a shortcut for `decorator(caller)(func)`.

`IPython.testing.decorator_msim.` `getinfo`(func)

  Returns an info dictionary containing: - name (the name of the function : str) - argnames (the names of the arguments : list) - defaults (the values of the default arguments : tuple) - signature (the signature : str) - doc (the docstring : str) - module (the module name : str) - dict (the function __dict__ : str)

      >>> def f(self, x=1, y=2, *args, **kw): pass

      >>> info = getinfo(f)

      >>> info["name"]
      'f'
      >>> info["argnames"]
      ['self', 'x', 'y', 'args', 'kw']

      >>> info["defaults"]
      (1, 2)

      >>> info["signature"]
      'self, x, y, *args, **kw'

`IPython.testing.decorator_msim.` `update_wrapper`(wrapper, wrapped, create=False)
  An improvement over functools.update_wrapper. By default it works the same, but if the ‘create’ flag is set, generates a copy of the wrapper with the right signature and update the copy, not the original. Moreovoer, ‘wrapped’ can be a dictionary with keys ‘name’, ‘doc’, ‘module’, ‘dict’, ‘defaults’.

### Navigation

- index
- modules |
- next |
- previous |
- IPython v0.10 documentation »
- The IPython API »