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.
This commit is contained in:
R. David Murray 2010-02-23 00:24:49 +00:00
parent 87bcb243ac
commit f28fd24c36
19 changed files with 194 additions and 41 deletions

View file

@ -2240,6 +2240,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):
"""
@ -2282,13 +2295,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