How to doctest if __name__ already used?

Leo Breebaart leo at lspace.org
Fri May 5 18:33:48 EDT 2006


I have a simple question (I hope), but one I'd love to get some
feedback on in case I am missing something obvious:

If I have a Python script that is executable, and therefore
already uses '''if __name__ == "__main__"''' to call a function
of its own, what is then the easiest yet still most Pythonic way
to run doctest on the docstrings in the file? 

Trigger doctest.testmod() via a "--test" command-line option, is
what I'm thinking. But is that really the best way?

-- 
Leo Breebaart  <leo at lspace.org>



More information about the Python-list mailing list