mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
gh-108794: doctest counts skipped tests (#108795)
* Add 'skipped' attribute to TestResults. * Add 'skips' attribute to DocTestRunner. * Rename private DocTestRunner._name2ft attribute to DocTestRunner._stats. * Use f-string for string formatting. * Add some tests. * Document DocTestRunner attributes and its API for statistics. * Document TestResults class. Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
4ba18099b7
commit
4f9b706c6f
5 changed files with 175 additions and 67 deletions
|
@ -748,6 +748,38 @@ and 'int' is a type.
|
|||
"""
|
||||
|
||||
|
||||
class TestDocTest(unittest.TestCase):
|
||||
|
||||
def test_run(self):
|
||||
test = '''
|
||||
>>> 1 + 1
|
||||
11
|
||||
>>> 2 + 3 # doctest: +SKIP
|
||||
"23"
|
||||
>>> 5 + 7
|
||||
57
|
||||
'''
|
||||
|
||||
def myfunc():
|
||||
pass
|
||||
myfunc.__doc__ = test
|
||||
|
||||
# test DocTestFinder.run()
|
||||
test = doctest.DocTestFinder().find(myfunc)[0]
|
||||
with support.captured_stdout():
|
||||
with support.captured_stderr():
|
||||
results = doctest.DocTestRunner(verbose=False).run(test)
|
||||
|
||||
# test TestResults
|
||||
self.assertIsInstance(results, doctest.TestResults)
|
||||
self.assertEqual(results.failed, 2)
|
||||
self.assertEqual(results.attempted, 3)
|
||||
self.assertEqual(results.skipped, 1)
|
||||
self.assertEqual(tuple(results), (2, 3))
|
||||
x, y = results
|
||||
self.assertEqual((x, y), (2, 3))
|
||||
|
||||
|
||||
class TestDocTestFinder(unittest.TestCase):
|
||||
|
||||
def test_issue35753(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue