summaryrefslogtreecommitdiffstats
path: root/Lib/doctest.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2012-09-10 14:16:46 (GMT)
committerR David Murray <rdmurray@bitdance.com>2012-09-10 14:16:46 (GMT)
commitc3bfb01a959235135c727d532e3e89bbf2658a09 (patch)
tree2f6dd0d97ea06d535f7b4349c28df02b7635396d /Lib/doctest.py
parentb83b287f17aa8f59e378f9d6ff77401c42d36dd3 (diff)
parent5abd76a75d633a1ba6f5fcc66b0bc4799b9e2eaa (diff)
downloadcpython-c3bfb01a959235135c727d532e3e89bbf2658a09.zip
cpython-c3bfb01a959235135c727d532e3e89bbf2658a09.tar.gz
cpython-c3bfb01a959235135c727d532e3e89bbf2658a09.tar.bz2
Merge #14649: clarify DocTestSuite error when there are no docstrings.
Also adds tests to verify the documented behavior (which is probably a bug, as indicated in the added comments). Patch by Chris Jerdonek.
Diffstat (limited to 'Lib/doctest.py')
-rw-r--r--Lib/doctest.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py
index 620451f..3af05fb 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -2334,7 +2334,12 @@ def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None,
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")
+ # 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 = unittest.TestSuite()