Skip to content

Commit 1da08e7

Browse files
committed
Merge #12757: Make doctest skipping in -OO mode work with unittest/regrtest -v
2 parents 520e850 + e112153 commit 1da08e7

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Lib/doctest.py

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

22692269
class SkipDocTestCase(DocTestCase):
2270-
def __init__(self):
2270+
def __init__(self, module):
2271+
self.module = module
22712272
DocTestCase.__init__(self, None)
22722273

22732274
def setUp(self):
@@ -2277,7 +2278,10 @@ def test_skip(self):
22772278
pass
22782279

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

22822286
def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None,
22832287
**options):
@@ -2325,7 +2329,7 @@ def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None,
23252329
if not tests and sys.flags.optimize >=2:
23262330
# Skip doctests when running with -O2
23272331
suite = unittest.TestSuite()
2328-
suite.addTest(SkipDocTestCase())
2332+
suite.addTest(SkipDocTestCase(module))
23292333
return suite
23302334
elif not tests:
23312335
# 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
@@ -30,6 +30,9 @@ Core and Builtins
3030
Library
3131
-------
3232

33+
- Issue #12757: Fix the skipping of doctests when python is run with -OO so
34+
that it works in unittest's verbose mode as well as non-verbose mode.
35+
3336
- Issue #7652: Integrate the decimal floating point libmpdec library to speed
3437
up the decimal module. Performance gains of the new C implementation are
3538
between 12x and 80x, depending on the application.

0 commit comments

Comments
 (0)