]> granicus.if.org Git - python/commitdiff
#12757: Make doctest skipping in -OO mode work with unittest/regrtest -v
authorR David Murray <rdmurray@bitdance.com>
Wed, 21 Mar 2012 18:53:42 +0000 (14:53 -0400)
committerR David Murray <rdmurray@bitdance.com>
Wed, 21 Mar 2012 18:53:42 +0000 (14:53 -0400)
Lib/doctest.py
Misc/NEWS

index 234733e5651c5359d2aee3704b6bd7494c76f54f..cc3b425075d9711914818248841897a4b80c8626 100644 (file)
@@ -2266,7 +2266,8 @@ class DocTestCase(unittest.TestCase):
         return "Doctest: " + self._dt_test.name
 
 class SkipDocTestCase(DocTestCase):
-    def __init__(self):
+    def __init__(self, module):
+        self.module = module
         DocTestCase.__init__(self, None)
 
     def setUp(self):
@@ -2276,7 +2277,10 @@ class SkipDocTestCase(DocTestCase):
         pass
 
     def shortDescription(self):
-        return "Skipping tests from %s" % module.__name__
+        return "Skipping tests from %s" % self.module.__name__
+
+    __str__ = shortDescription
+
 
 def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None,
                  **options):
@@ -2324,7 +2328,7 @@ def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None,
     if not tests and sys.flags.optimize >=2:
         # Skip doctests when running with -O2
         suite = unittest.TestSuite()
-        suite.addTest(SkipDocTestCase())
+        suite.addTest(SkipDocTestCase(module))
         return suite
     elif not tests:
         # Why do we want to do this? Because it reveals a bug that might
index dcf4e2359d85973fcd91083a308b0bd01a67e62d..606898f6d2c4acb61ad4bf9814f29ed7ca456273 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -28,6 +28,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #12757: Fix the skipping of doctests when python is run with -OO so
+  that it works in unittest's verbose mode as well as non-verbose mode.
+
 - Issue #3573: IDLE hangs when passing invalid command line args
   (directory(ies) instead of file(s)) (Patch by Guilherme Polo)