]> 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 19:02:30 +0000 (15:02 -0400)
committerR David Murray <rdmurray@bitdance.com>
Wed, 21 Mar 2012 19:02:30 +0000 (15:02 -0400)
Lib/doctest.py
Misc/NEWS

index 8297fad96025bb3121e37c9c82df9e5971ceba1d..095f560502061f82ea4bcb1a7a1d06dab3e637b2 100644 (file)
@@ -2314,7 +2314,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):
@@ -2324,7 +2325,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):
@@ -2372,7 +2376,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 65b5c1723f78fc23f000191f58c28bf764f6ffad..5f715cfc8640eeed724fb3ef7b32628624ba8692 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -27,6 +27,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)