FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.10] bpo-45229: Make doctest tests discoverable (GH-28986) by miss-islington · Pull Request #29095 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
20 changes: 6 additions & 14 deletions Lib/test/test_doctest.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3110,20 +3110,11 @@ def test_no_trailing_whitespace_stripping():
patches that contain trailing whitespace. More info on Issue 24746.
"""

######################################################################
## Main
######################################################################

def test_main():
# Check the doctest cases in doctest itself:
ret = support.run_doctest(doctest, verbosity=True)

# Check the doctest cases defined here:
from test import test_doctest
support.run_doctest(test_doctest, verbosity=True)

# Run unittests
support.run_unittest(__name__)
def load_tests(loader, tests, pattern):
tests.addTest(doctest.DocTestSuite(doctest))
tests.addTest(doctest.DocTestSuite())
return tests


def test_coverage(coverdir):
Expand All @@ -3136,8 +3127,9 @@ def test_coverage(coverdir):
r.write_results(show_missing=True, summary=True,
coverdir=coverdir)


if __name__ == '__main__':
if '-c' in sys.argv:
test_coverage('/tmp/doctest.cover')
else:
test_main()
unittest.main()
21 changes: 12 additions & 9 deletions Lib/test/test_doctest2.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import sys
import unittest
from test import support
if sys.flags.optimize >= 2:
raise unittest.SkipTest("Cannot test docstrings with -O2")

Expand Down Expand Up @@ -107,17 +106,21 @@ def clsm(cls, val):
"""
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()

Back | FazBrowse Home | New Git URL