doctest x idle problem?

Tim Peters tim.one at home.com
Wed Jul 25 19:25:12 EDT 2001


[Jon Schull]
> If I run "python doctest.py" from the command line (win2K) doctest
> does what I'd expect (which in this case is nothing).
>
> If I load doctest.py into idle and go "Edit| Run Script" I get
> something similar(a blank line).
>
> But if I go "Edit| Run Script" again, I get a Whole Bunch of Stuff
> (and doctest seems not be testing docstrings).  Is there a right way
> to have doctest and idle coexist?
>
> Here follows a Whole Bunch of Stuff ....
> *** Tester.merge: 'doctest.testmod' in both testers; summing outcomes.
> [and lots more of the same]

You should read the "ADVANCED USAGE" section of doctest.py's module
docstring.  What you're seeing is that doctest maintains a (module-global)
instance of class doctest.Tester, in module variable doctest.master, into
which any number of doctest runs can merge their results.  If you run
doctest on itself multiple times, then it will try to merge the results of
all those runs into one master report, and Tester.merge warns you when it
sees multiple tests with the same name.

That said, I have no idea why you're doing "Run Script" on doctest to begin
with.  That's not a sensible thing to do -- doctest is a library module in
2.1, and you shouldn't need to load it into IDLE at all, let alone ever run
it on itself.

If for some reason you simply can't resist <wink>, set "master" to None
between useless runs so that doctest stops trying to merge their redundant
results.





More information about the Python-list mailing list