File tree 2 files changed +18
-23
lines changed
2 files changed +18
-23
lines changed Original file line number Diff line number Diff line change @@ -3091,20 +3091,11 @@ def test_no_trailing_whitespace_stripping():
3091
3091
patches that contain trailing whitespace. More info on Issue 24746.
3092
3092
"""
3093
3093
3094
- ######################################################################
3095
- ## Main
3096
- ######################################################################
3097
-
3098
- def test_main ():
3099
- # Check the doctest cases in doctest itself:
3100
- ret = support .run_doctest (doctest , verbosity = True )
3101
3094
3102
- # Check the doctest cases defined here:
3103
- from test import test_doctest
3104
- support .run_doctest (test_doctest , verbosity = True )
3105
-
3106
- # Run unittests
3107
- support .run_unittest (__name__ )
3095
+ def load_tests (loader , tests , pattern ):
3096
+ tests .addTest (doctest .DocTestSuite (doctest ))
3097
+ tests .addTest (doctest .DocTestSuite ())
3098
+ return tests
3108
3099
3109
3100
3110
3101
def test_coverage (coverdir ):
@@ -3117,8 +3108,9 @@ def test_coverage(coverdir):
3117
3108
r .write_results (show_missing = True , summary = True ,
3118
3109
coverdir = coverdir )
3119
3110
3111
+
3120
3112
if __name__ == '__main__' :
3121
3113
if '-c' in sys .argv :
3122
3114
test_coverage ('/tmp/doctest.cover' )
3123
3115
else :
3124
- test_main ()
3116
+ unittest . main ()
Original file line number Diff line number Diff line change 13
13
14
14
import sys
15
15
import unittest
16
- from test import support
17
16
if sys .flags .optimize >= 2 :
18
17
raise unittest .SkipTest ("Cannot test docstrings with -O2" )
19
18
@@ -107,17 +106,21 @@ def clsm(cls, val):
107
106
"""
108
107
return val
109
108
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
+
117
120
118
121
# Pollute the namespace with a bunch of imported functions and classes,
119
122
# to make sure they don't get tested.
120
123
from doctest import *
121
124
122
125
if __name__ == '__main__' :
123
- test_main ()
126
+ unittest . main ()
You can’t perform that action at this time.
0 commit comments