File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -913,18 +913,16 @@ Unittest API
913913As your collection of doctest'ed modules grows, you'll want a way to run all
914914their doctests systematically. :mod: `doctest ` provides two functions that can
915915be used to create :mod: `unittest ` test suites from modules and text files
916- containing doctests. These test suites can then be run using :mod: `unittest `
917- test runners ::
916+ containing doctests. To integrate with :mod: `unittest ` test discovery, include
917+ a :func: ` load_tests ` function in your test module ::
918918
919919 import unittest
920920 import doctest
921- import my_module_with_doctests, and_another
921+ import my_module_with_doctests
922922
923- suite = unittest.TestSuite()
924- for mod in my_module_with_doctests, and_another:
925- suite.addTest(doctest.DocTestSuite(mod))
926- runner = unittest.TextTestRunner()
927- runner.run(suite)
923+ def load_tests(loader, tests, ignore):
924+ tests.addTests(doctest.DocTestSuite(my_module_with_doctests))
925+ return test
928926
929927There are two main functions for creating :class: `unittest.TestSuite ` instances
930928from text files and modules with doctests:
You can’t perform that action at this time.
0 commit comments