This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author yemir
Recipients
Date 2006-11-12.08:31:52
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
"23.2.1 Simple Usage: Checking Examples in Docstrings" sets up a trap 
for the unsuspecting developer:

    http://docs.python.org/lib/doctest-simple-testmod.html

That page recommends adding the following code to the end of a 
module using doctest:

    def _test():
        import doctest
        doctest.testmod()

    if __name__ == "__main__":
        _test()

The problem is that a reasonable person will figure that _test() has 
been defined for convenience in executing the tests from other Python 
code as follows:

    import M
    M._test()

However, that executes the doctests found in __main__, not M!

I think the recommended recipe should instead be as follows:

    if __name__ == "__main__":
        import doctest
        doctest.testmod()
History
Date User Action Args
2007-08-23 14:49:41adminlinkissue1594966 messages
2007-08-23 14:49:41admincreate