A DocTestSuite cannot run multiple times: it clears its globals dictionary after the first run.

Rebuild the DocTestSuite on each iteration.
This commit is contained in:
Amaury Forgeot d'Arc 2008-04-02 00:55:04 +00:00
parent 4d0c1170ef
commit cb0f2ad0c2
1 changed files with 2 additions and 3 deletions

View File

@ -305,13 +305,12 @@ class TestCollectionABCs(unittest.TestCase):
self.failIf(issubclass(basestring, MutableSequence))
import doctest, collections
NamedTupleDocs = doctest.DocTestSuite(module=collections)
def test_main(verbose=None):
import collections as CollectionsModule
NamedTupleDocs = doctest.DocTestSuite(module=collections)
test_classes = [TestNamedTuple, NamedTupleDocs, TestOneTrickPonyABCs, TestCollectionABCs]
test_support.run_unittest(*test_classes)
test_support.run_doctest(CollectionsModule, verbose)
test_support.run_doctest(collections, verbose)
if __name__ == "__main__":
test_main(verbose=True)