diff -r e8acef4f8567 Lib/doctest.py --- a/Lib/doctest.py Sun Apr 13 19:55:08 2014 +0300 +++ b/Lib/doctest.py Mon Apr 14 13:59:46 2014 -0400 @@ -2376,15 +2376,6 @@ 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() diff -r e8acef4f8567 Lib/test/test_doctest.py --- a/Lib/test/test_doctest.py Sun Apr 13 19:55:08 2014 +0300 +++ b/Lib/test/test_doctest.py Mon Apr 14 13:59:46 2014 -0400 @@ -2096,22 +2096,9 @@ >>> suite.run(unittest.TestResult()) - However, if DocTestSuite finds no docstrings, it raises an error: - - >>> try: - ... doctest.DocTestSuite('test.sample_doctest_no_docstrings') - ... except ValueError as e: - ... error = e - - >>> print(error.args[1]) - has no docstrings - - You can prevent this error by passing a DocTestFinder instance with - the `exclude_empty` keyword argument set to False: - - >>> finder = doctest.DocTestFinder(exclude_empty=False) - >>> suite = doctest.DocTestSuite('test.sample_doctest_no_docstrings', - ... test_finder=finder) + The module need not contain any docstrings either: + + >>> suite = doctest.DocTestSuite('test.sample_doctest_no_docstrings') >>> suite.run(unittest.TestResult()) @@ -2121,6 +2108,22 @@ >>> suite.run(unittest.TestResult()) + We can also provide a DocTestFinder: + + >>> finder = doctest.DocTestFinder() + >>> suite = doctest.DocTestSuite('test.sample_doctest', + ... test_finder=finder) + >>> suite.run(unittest.TestResult()) + + + The DocTestFinder need not return any tests: + + >>> finder = doctest.DocTestFinder() + >>> suite = doctest.DocTestSuite('test.sample_doctest_no_docstrings', + ... test_finder=finder) + >>> suite.run(unittest.TestResult()) + + We can supply global variables. If we pass globs, they will be used instead of the module globals. Here we'll pass an empty globals, triggering an extra error: