diff -r 472494ced67f Doc/library/doctest.rst --- a/Doc/library/doctest.rst Sat Apr 06 20:53:12 2013 -0700 +++ b/Doc/library/doctest.rst Sun Apr 07 16:01:08 2013 +0300 @@ -1018,7 +1018,7 @@ from a text file using :func:`DocFileSuite`. -.. function:: DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None, setUp=None, tearDown=None, checker=None) +.. function:: DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None, test_class=DocTestCase, setUp=None, tearDown=None, checker=None, runner=None) Convert doctest tests for a module to a :class:`unittest.TestSuite`. @@ -1042,9 +1042,20 @@ Optional argument *test_finder* is the :class:`DocTestFinder` object (or a drop-in replacement) that is used to extract doctests from the module. + Optional argument *test_class* is the :class:`doctest.DocTestCase` object + (or a drop-in replacement) that is used to override default test class for + test suite. It defaults to :class:`doctest.DocTestCase` + Optional arguments *setUp*, *tearDown*, and *optionflags* are the same as for function :func:`DocFileSuite` above. + Optional argument *runner* is the :class:`DocTestRunner` object (or a + drop-in replacement) that is used to extract doctests from the module. + + Optional argument *checker* specifies the :class:`OutputCheker` object (or a + drop-in replacement) that is used to compare the expected outputs to the + actual outputs of doctest examples. + This function uses the same search technique as :func:`testmod`. .. note:: diff -r 472494ced67f Lib/doctest.py --- a/Lib/doctest.py Sat Apr 06 20:53:12 2013 -0700 +++ b/Lib/doctest.py Sun Apr 07 16:01:08 2013 +0300 @@ -2112,7 +2112,7 @@ class DocTestCase(unittest.TestCase): def __init__(self, test, optionflags=0, setUp=None, tearDown=None, - checker=None): + checker=None, runner=DocTestRunner): unittest.TestCase.__init__(self) self._dt_optionflags = optionflags @@ -2120,6 +2120,7 @@ self._dt_test = test self._dt_setUp = setUp self._dt_tearDown = tearDown + self._dt_runner = runner def setUp(self): test = self._dt_test @@ -2146,7 +2147,7 @@ # so add the default reporting flags optionflags |= _unittest_reportflags - runner = DocTestRunner(optionflags=optionflags, + runner = self._dt_runner(optionflags=optionflags, checker=self._dt_checker, verbose=False) try: @@ -2290,7 +2291,7 @@ def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None, - **options): + test_class=DocTestCase, **options): """ Convert doctest tests for a module to a unittest test suite. @@ -2358,7 +2359,7 @@ if filename[-4:] in (".pyc", ".pyo"): filename = filename[:-1] test.filename = filename - suite.addTest(DocTestCase(test, **options)) + suite.addTest(test_class(test, **options)) return suite