[New-bugs-announce] [issue1108] Problem with doctest and decorated functions
report at bugs.python.org
Wed Sep 5 12:53:25 CEST 2007
New submission from Daniel Larsson:
Seems like doctest won't recognize functions inside the module under
test are actually in that module, if the function is decorated by a
decorator that wraps the function in an externally defined function,
such as in this silly example:
def new_f(*args, **kwds):
print "Wrapper calling func"
return f(*args, **kwds)
from decorator import simplelog
This test should fail, since the decorator prints output.
Seems I don't get called though
if __name__ == '__main__':
The problem lies in DocTestFinder._from_module, which checks if the
function's func_globals attribute is the same as the module's __dict__
I'd propose to do the __module__/inspect.getmodule() checks (aren't they
both checking the same thing btw?) before the inspect.isfunction check.
components: Library (Lib)
title: Problem with doctest and decorated functions
versions: Python 2.5
Tracker <report at bugs.python.org>
More information about the New-bugs-announce