import functools def foo(): """ >>> 'one test' 'one test' """ class Wrapper: def __init__(self, func): self.func = func functools.update_wrapper(self, func) def __call__(self, *args, **kwargs): self.func(*args, **kwargs) @Wrapper def bar(): """ >>> 'one other test' 'one other test' """ assert 'one other test' in bar.__doc__ if __name__ == "__main__": import doctest doctest.testmod(verbose=True)