doctest not seeing any of my doc tests

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sun Sep 7 09:40:02 EDT 2008


I have a function in my module:

def selftest(verbose=False):
    import doctest
    doctest.testmod(verbose=verbose)


When I run it, it fails to find any of my doc tests, including the tests 
in __main__, and in fact it looks like it can't even find my functions 
and classes:


>>> mymodule.selftest(True)
1 items had no tests:
    __main__
0 tests in 1 items.
0 passed and 0 failed.
Test passed.


The second and subsequent times I call selftest, I get the same result 
except that it adds this line to the end:

*** DocTestRunner.merge: '__main__' in both testers; summing outcomes.


I've exited from Python and restarted the interactive interpreter. I've 
deleted the module .pyc file. Neither has helped.

I've tried reading over the doctest module to see if there are any hints 
as to what's going wrong, but it's quite opaque to me. If there's anyone 
out there with a good understanding of doctest, I'd appreciate some 
pointers for where to start looking, or otherwise how to fix this problem.

For what it's worth, I'm running 

Python 2.5 (r25:51908, Apr 10 2007, 10:29:13)
[GCC 4.1.2 20070403 (Red Hat 4.1.2-8)] on linux2




-- 
Steven



More information about the Python-list mailing list