[Python-checkins] cpython (merge 3.2 -> default): Merge #12757: Make doctest skipping in -OO mode work with unittest/regrtest -v

r.david.murray python-checkins at python.org
Wed Mar 21 20:02:43 CET 2012


http://hg.python.org/cpython/rev/ff7957aa01a1
changeset:   75860:ff7957aa01a1
parent:      75858:bd4243dc0741
parent:      75859:64f1b8ad9214
user:        R David Murray <rdmurray at bitdance.com>
date:        Wed Mar 21 14:55:04 2012 -0400
summary:
  Merge #12757: Make doctest skipping in -OO mode work with unittest/regrtest -v

files:
  Lib/doctest.py |  10 +++++++---
  Misc/NEWS      |   3 +++
  2 files changed, 10 insertions(+), 3 deletions(-)


diff --git a/Lib/doctest.py b/Lib/doctest.py
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -2267,7 +2267,8 @@
         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):
@@ -2277,7 +2278,10 @@
         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):
@@ -2325,7 +2329,7 @@
     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
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -30,6 +30,9 @@
 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 #7652: Integrate the decimal floating point libmpdec library to speed
   up the decimal module. Performance gains of the new C implementation are
   between 12x and 80x, depending on the application.

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list