summaryrefslogtreecommitdiff
path: root/Lib/test/test_doctest2.py
diff options
context:
space:
mode:
authorEthan Furman <ethan@stoneleaf.us>2021-10-20 20:55:46 -0700
committerGitHub <noreply@github.com>2021-10-20 20:55:46 -0700
commitc52338fc42353e8d0c6214e4c22427807439dfd5 (patch)
tree6da4bf5da5eb739aa48eab1850218d5726c45b10 /Lib/test/test_doctest2.py
parent8f05ffb0534c2343fc45ad0e1d91ae1dc2d92b64 (diff)
parent2a9ab75af32b1ee9f210ae2a0718990687d0f79d (diff)
downloadcpython-git-enum-private-310.tar.gz
Merge branch '3.10' into enum-private-310enum-private-310
Diffstat (limited to 'Lib/test/test_doctest2.py')
-rw-r--r--Lib/test/test_doctest2.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/Lib/test/test_doctest2.py b/Lib/test/test_doctest2.py
index 347a143641..ab8a069673 100644
--- a/Lib/test/test_doctest2.py
+++ b/Lib/test/test_doctest2.py
@@ -13,7 +13,6 @@ the example. It should be ignored:
import sys
import unittest
-from test import support
if sys.flags.optimize >= 2:
raise unittest.SkipTest("Cannot test docstrings with -O2")
@@ -107,17 +106,21 @@ class C(object):
"""
return val
-def test_main():
- from test import test_doctest2
- EXPECTED = 19
- f, t = support.run_doctest(test_doctest2)
- if t != EXPECTED:
- raise support.TestFailed("expected %d tests to run, not %d" %
- (EXPECTED, t))
+
+class Test(unittest.TestCase):
+ def test_testmod(self):
+ import doctest, sys
+ EXPECTED = 19
+ f, t = doctest.testmod(sys.modules[__name__])
+ if f:
+ self.fail("%d of %d doctests failed" % (f, t))
+ if t != EXPECTED:
+ self.fail("expected %d tests to run, not %d" % (EXPECTED, t))
+
# Pollute the namespace with a bunch of imported functions and classes,
# to make sure they don't get tested.
from doctest import *
if __name__ == '__main__':
- test_main()
+ unittest.main()