doctest in Pythonwin
tim.one at comcast.net
Sat Aug 10 04:12:28 CEST 2002
> Running the following boilerplate from the library docs
> def _test():
> import doctest, doctesttest
> if __name__ == '__main__':
> 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
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