S
Steven D'Aprano
I've just spotted a bug in doctest that it fails to see tests inside
decorated functions. It's been reported before:
http://bugs.python.org/issue1108
but the patch submitted doesn't work for me. I have a test script on the
page demonstrating the problem. Can anyone give me some clues as to a
work-around? I tried adding objects to __test__ but testmod() still failed
to pick up their tests.
if __name__ == '__main__':
import doctest
import types
__test__ = {}
allowed = [str, types.FunctionType,
types.ClassType, types.GeneratorType,
types.MethodType, types.UnboundMethodType]
for name in dir():
obj = vars()[name]
if type(obj) in allowed:
__test__[name] = obj
doctest.testmod()
decorated functions. It's been reported before:
http://bugs.python.org/issue1108
but the patch submitted doesn't work for me. I have a test script on the
page demonstrating the problem. Can anyone give me some clues as to a
work-around? I tried adding objects to __test__ but testmod() still failed
to pick up their tests.
if __name__ == '__main__':
import doctest
import types
__test__ = {}
allowed = [str, types.FunctionType,
types.ClassType, types.GeneratorType,
types.MethodType, types.UnboundMethodType]
for name in dir():
obj = vars()[name]
if type(obj) in allowed:
__test__[name] = obj
doctest.testmod()