summaryrefslogtreecommitdiffstats
path: root/Lib/doctest.py
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2010-02-24 01:46:21 (GMT)
committerR. David Murray <rdmurray@bitdance.com>2010-02-24 01:46:21 (GMT)
commit378c0cf5abb4c49c1a95597d3c5284dc93dd7822 (patch)
tree0a7c9a724887dff98a5abefd9b09da0de6889731 /Lib/doctest.py
parent72aee3dcabf98a0b8a7a60cccab4fbd1ef63fbd2 (diff)
downloadcpython-378c0cf5abb4c49c1a95597d3c5284dc93dd7822.zip
cpython-378c0cf5abb4c49c1a95597d3c5284dc93dd7822.tar.gz
cpython-378c0cf5abb4c49c1a95597d3c5284dc93dd7822.tar.bz2
Merged revisions 78351 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r78351 | r.david.murray | 2010-02-22 19:24:49 -0500 (Mon, 22 Feb 2010) | 5 lines Issue 6292: for the moment at least, the test suite passes if run with -OO. Tests requiring docstrings are skipped. Patch by Brian Curtin, thanks to Matias Torchinsky for helping review and improve the patch. ........
Diffstat (limited to 'Lib/doctest.py')
-rw-r--r--Lib/doctest.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py
index d6fb504..eac4378 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -2192,6 +2192,19 @@ class DocTestCase(unittest.TestCase):
def shortDescription(self):
return "Doctest: " + self._dt_test.name
+class SkipDocTestCase(DocTestCase):
+ def __init__(self):
+ DocTestCase.__init__(self, None)
+
+ def setUp(self):
+ self.skipTest("DocTestSuite will not work with -O2 and above")
+
+ def test_skip(self):
+ pass
+
+ def shortDescription(self):
+ return "Skipping tests from %s" % module.__name__
+
def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None,
**options):
"""
@@ -2234,13 +2247,20 @@ def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None,
module = _normalize_module(module)
tests = test_finder.find(module, globs=globs, extraglobs=extraglobs)
- if not tests:
+
+ if not tests and sys.flags.optimize >=2:
+ # Skip doctests when running with -O2
+ suite = unittest.TestSuite()
+ suite.addTest(SkipDocTestCase())
+ return suite
+ elif not tests:
# Why do we want to do this? Because it reveals a bug that might
# otherwise be hidden.
raise ValueError(module, "has no tests")
tests.sort()
suite = unittest.TestSuite()
+
for test in tests:
if len(test.examples) == 0:
continue