Kaydet (Commit) a8514835 authored tarafından Georg Brandl's avatar Georg Brandl

#8564: update docs on integrating doctest/unittest with unittest(2) test discovery.

üst 1c616a5c
...@@ -913,18 +913,16 @@ Unittest API ...@@ -913,18 +913,16 @@ Unittest API
As your collection of doctest'ed modules grows, you'll want a way to run all As your collection of doctest'ed modules grows, you'll want a way to run all
their doctests systematically. :mod:`doctest` provides two functions that can their doctests systematically. :mod:`doctest` provides two functions that can
be used to create :mod:`unittest` test suites from modules and text files be used to create :mod:`unittest` test suites from modules and text files
containing doctests. These test suites can then be run using :mod:`unittest` containing doctests. To integrate with :mod:`unittest` test discovery, include
test runners:: a :func:`load_tests` function in your test module::
import unittest import unittest
import doctest import doctest
import my_module_with_doctests, and_another import my_module_with_doctests
suite = unittest.TestSuite() def load_tests(loader, tests, ignore):
for mod in my_module_with_doctests, and_another: tests.addTests(doctest.DocTestSuite(my_module_with_doctests))
suite.addTest(doctest.DocTestSuite(mod)) return test
runner = unittest.TextTestRunner()
runner.run(suite)
There are two main functions for creating :class:`unittest.TestSuite` instances There are two main functions for creating :class:`unittest.TestSuite` instances
from text files and modules with doctests: from text files and modules with doctests:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment