File tree Expand file tree Collapse file tree 2 files changed +18
-23
lines changed
Expand file tree Collapse file tree 2 files changed +18
-23
lines changed Original file line number Diff line number Diff line change @@ -3114,20 +3114,11 @@ def test_no_trailing_whitespace_stripping():
31143114 patches that contain trailing whitespace. More info on Issue 24746.
31153115 """
31163116
3117- ######################################################################
3118- ## Main
3119- ######################################################################
3120-
3121- def test_main ():
3122- # Check the doctest cases in doctest itself:
3123- ret = support .run_doctest (doctest , verbosity = True )
31243117
3125- # Check the doctest cases defined here:
3126- from test import test_doctest
3127- support .run_doctest (test_doctest , verbosity = True )
3128-
3129- # Run unittests
3130- support .run_unittest (__name__ )
3118+ def load_tests (loader , tests , pattern ):
3119+ tests .addTest (doctest .DocTestSuite (doctest ))
3120+ tests .addTest (doctest .DocTestSuite ())
3121+ return tests
31313122
31323123
31333124def test_coverage (coverdir ):
@@ -3140,8 +3131,9 @@ def test_coverage(coverdir):
31403131 r .write_results (show_missing = True , summary = True ,
31413132 coverdir = coverdir )
31423133
3134+
31433135if __name__ == '__main__' :
31443136 if '-c' in sys .argv :
31453137 test_coverage ('/tmp/doctest.cover' )
31463138 else :
3147- test_main ()
3139+ unittest . main ()
Original file line number Diff line number Diff line change 1313
1414import sys
1515import unittest
16- from test import support
1716if sys .flags .optimize >= 2 :
1817 raise unittest .SkipTest ("Cannot test docstrings with -O2" )
1918
@@ -107,17 +106,21 @@ def clsm(cls, val):
107106 """
108107 return val
109108
110- def test_main ():
111- from test import test_doctest2
112- EXPECTED = 19
113- f , t = support .run_doctest (test_doctest2 )
114- if t != EXPECTED :
115- raise support .TestFailed ("expected %d tests to run, not %d" %
116- (EXPECTED , t ))
109+
110+ class Test (unittest .TestCase ):
111+ def test_testmod (self ):
112+ import doctest , sys
113+ EXPECTED = 19
114+ f , t = doctest .testmod (sys .modules [__name__ ])
115+ if f :
116+ self .fail ("%d of %d doctests failed" % (f , t ))
117+ if t != EXPECTED :
118+ self .fail ("expected %d tests to run, not %d" % (EXPECTED , t ))
119+
117120
118121# Pollute the namespace with a bunch of imported functions and classes,
119122# to make sure they don't get tested.
120123from doctest import *
121124
122125if __name__ == '__main__' :
123- test_main ()
126+ unittest . main ()
You can’t perform that action at this time.
0 commit comments