diff options
author | R David Murray <rdmurray@bitdance.com> | 2014-04-14 20:28:36 -0400 |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2014-04-14 20:28:36 -0400 |
commit | 1976d9bf6d5525821e1cb005a05acbf55a340dfa (patch) | |
tree | e0eb0c501c59ef769da9599aa921ea88dd49cad8 /Lib/doctest.py | |
parent | Merge: #15104: add backtick code markup. (diff) | |
download | cpython-1976d9bf6d5525821e1cb005a05acbf55a340dfa.tar.gz cpython-1976d9bf6d5525821e1cb005a05acbf55a340dfa.tar.bz2 cpython-1976d9bf6d5525821e1cb005a05acbf55a340dfa.zip |
#15916: if there are no docstrings, make empty suite, not an error.
This makes doctest work like unittest: if the test case is empty, that
just means there are zero tests run, it's not an error. The existing
behavior was broken, since it only gave an error if there were *no*
docstrings, and zero tests run if there were docstrings but none of them
contained tests. So this makes it self-consistent as well.
Patch by Glenn Jones.
Diffstat (limited to 'Lib/doctest.py')
-rw-r--r-- | Lib/doctest.py | 9 |
1 files changed, 0 insertions, 9 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py index d212ad6be1e..be824f45d8b 100644 --- a/Lib/doctest.py +++ b/Lib/doctest.py @@ -2376,15 +2376,6 @@ def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None, suite = _DocTestSuite() suite.addTest(SkipDocTestCase(module)) return suite - elif not tests: - # Why do we want to do this? Because it reveals a bug that might - # otherwise be hidden. - # It is probably a bug that this exception is not also raised if the - # number of doctest examples in tests is zero (i.e. if no doctest - # examples were found). However, we should probably not be raising - # an exception at all here, though it is too late to make this change - # for a maintenance release. See also issue #14649. - raise ValueError(module, "has no docstrings") tests.sort() suite = _DocTestSuite() |