doctest and decorators
Michele Simionato
michele.simionato at gmail.com
Wed Sep 5 06:42:23 EDT 2007
On 9/5/07, Daniel Larsson <daniel.j.larsson at gmail.com> wrote:
> Here's my two files again:
>
> # decorator.py
> import functools
>
> def simplelog(f):
> @functools.wraps(f)
> def new_f(*args, **kwds):
> print "Wrapper calling func"
> return f(*args, **kwds)
> return new_f
>
> # test.py
> from decorator import simplelog
>
> @simplelog
> def test():
> """
> This test should fail, since the decorator prints output. Seems I don't
> get called though
> >>> test()
> 'works!'
> """
> return "works!"
>
> if __name__ == '__main__':
> import doctest
> doctest.testmod()
>
Ok, I could not see the code before (Google groups as getting worse as
the time goes by). It looks like you are right, it is a bug in
doctest.
Michele Simionato
More information about the Python-list
mailing list