Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e112153

Browse files
committed
#12757: Make doctest skipping in -OO mode work with unittest/regrtest -v
1 parent 0f71f44 commit e112153

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

Lib/doctest.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2266,7 +2266,8 @@ def shortDescription(self):
22662266
return "Doctest: " + self._dt_test.name
22672267

22682268
class SkipDocTestCase(DocTestCase):
2269-
def __init__(self):
2269+
def __init__(self, module):
2270+
self.module = module
22702271
DocTestCase.__init__(self, None)
22712272

22722273
def setUp(self):
@@ -2276,7 +2277,10 @@ def test_skip(self):
22762277
pass
22772278

22782279
def shortDescription(self):
2279-
return "Skipping tests from %s" % module.__name__
2280+
return "Skipping tests from %s" % self.module.__name__
2281+
2282+
__str__ = shortDescription
2283+
22802284

22812285
def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None,
22822286
**options):
@@ -2324,7 +2328,7 @@ def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None,
23242328
if not tests and sys.flags.optimize >=2:
23252329
# Skip doctests when running with -O2
23262330
suite = unittest.TestSuite()
2327-
suite.addTest(SkipDocTestCase())
2331+
suite.addTest(SkipDocTestCase(module))
23282332
return suite
23292333
elif not tests:
23302334
# Why do we want to do this? Because it reveals a bug that might

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ Core and Builtins
2828
Library
2929
-------
3030

31+
- Issue #12757: Fix the skipping of doctests when python is run with -OO so
32+
that it works in unittest's verbose mode as well as non-verbose mode.
33+
3134
- Issue #3573: IDLE hangs when passing invalid command line args
3235
(directory(ies) instead of file(s)) (Patch by Guilherme Polo)
3336

0 commit comments

Comments
 (0)