[issue4899] doctest should support fixtures

Alexander Belopolsky report at bugs.python.org
Wed Jan 14 00:15:54 CET 2009


Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:

The OP's problem, i.e. the need to reimport modules in every docstring 
can  easily be addressed by injecting the necessary names using 
extraglobs argument to doctest.testmod().

I like the following trick:

def getextraglobs():
   import StringIO, tempfile, ...
   return locals()
doctest.testmod(extraglobs=getextraglobs())

This however does not solve a problem of cleanup after examples and some 
way to specify a tearDown fixture would be helpful, particularly because  
cleanup code in examples will rarely improve documentation.

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4899>
_______________________________________


More information about the Python-bugs-list mailing list