def transplant_func(func, module):
from nose.tools import make_decorator<EOL>def newfunc(*arg, **kw):<EOL><INDENT>return func(*arg, **kw)<EOL><DEDENT>newfunc = make_decorator(func)(newfunc)<EOL>newfunc.__module__ = module<EOL>return newfunc<EOL>
Make a function imported from module A appear as if it is located
in module B.

>>> from pprint import pprint
>>> pprint.__module__
'pprint'
>>> pp = transplant_func(pprint, __name__)
>>> pp.__module__
'nose.util'

The original function is not modified.

>>> pprint.__module__
'pprint'

Calling the transplanted function calls the original.

>>> pp([1, 2])
[1, 2]
>>> pprint([1,2])
[1, 2]