doctest in Pythonwin
Tim Peters
tim.one at comcast.net
Fri Aug 9 22:12:28 EDT 2002
[Terry Reedy]
> Running the following boilerplate from the library docs
>
> #doctesttest.py
>
> def _test():
> import doctest, doctesttest
> doctest.testmod(doctesttest)
>
> if __name__ == '__main__':
> _test()
>
> gives the following output instead of the nothing promised by the docs
>
> >>> *** Tester.merge: 'doctesttest' in both testers; summing outcomes.
>
> For one file, I also got similar lines for each function, but have not
> yet discerned the rule. Is this an unavoidable peculiarity of running
> doctest in this environment?
I'm betting you ran a doctest more than once in your PythonWin session, and
that you didn't get this message the very first time you ran a doctest. As
explained in doctest's large docstrings <wink>, advanced uses of doctest
rely on that doctest maintains state across invocations, in order to merge
results from multiple runs. If you run a test with a given name more than
once, the grand-summary accumulator inside doctest spits out that message to
let you know you're (at best) double-counting. It would often be better if
IDEs spawned a new process when running files (there are many ways you can
get tripped up in IDLE, and I expect PythonWin too, by that sys.modules
persists across script runs).
In this particular case, you can worm around it by doing
import doctest
doctest.master = None
before each doctest run (that destroys doctest's accumulator -- but doctest
will create it again, so you have to keep doing this).
More information about the Python-list
mailing list