diff -r 61e6ac40c816 Lib/doctest.py --- a/Lib/doctest.py Thu Jul 05 20:57:33 2012 +0200 +++ b/Lib/doctest.py Fri Jul 06 05:26:15 2012 -0700 @@ -2334,7 +2334,7 @@ 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") + raise ValueError(module, "has no docstrings") tests.sort() suite = unittest.TestSuite() diff -r 61e6ac40c816 Lib/test/sample_doctest2.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/sample_doctest2.py Fri Jul 06 05:26:15 2012 -0700 @@ -0,0 +1,15 @@ +"""This is a sample module used for testing doctest. + +This module is for testing how doctest handles a module with docstrings +but no doctest examples. + +""" + + +class Foo(object): + """A docstring with no doctest examples. + + """ + + def __init__(self): + pass diff -r 61e6ac40c816 Lib/test/sample_doctest3.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/test/sample_doctest3.py Fri Jul 06 05:26:15 2012 -0700 @@ -0,0 +1,12 @@ +# This is a sample module used for testing doctest. +# +# This module is for testing how doctest handles a module with no +# docstrings. + + +class Foo(object): + + # A class with no docstring. + + def __init__(self): + pass diff -r 61e6ac40c816 Lib/test/test_doctest.py --- a/Lib/test/test_doctest.py Thu Jul 05 20:57:33 2012 +0200 +++ b/Lib/test/test_doctest.py Fri Jul 06 05:26:15 2012 -0700 @@ -1986,6 +1986,22 @@ >>> suite.run(unittest.TestResult()) + The module need not contain any doctest examples: + + >>> suite = doctest.DocTestSuite('test.sample_doctest2') + >>> suite.run(unittest.TestResult()) + + + However, if DocTestSuite finds no docstrings, it raises an error: + + >>> try: + ... doctest.DocTestSuite('test.sample_doctest3') + ... except ValueError as e: + ... error = e + + >>> print(error.args[1]) + has no docstrings + We can use the current module: >>> suite = test.sample_doctest.test_suite() diff -r 61e6ac40c816 Misc/ACKS --- a/Misc/ACKS Thu Jul 05 20:57:33 2012 +0200 +++ b/Misc/ACKS Fri Jul 06 05:26:15 2012 -0700 @@ -505,6 +505,7 @@ Drew Jenkins Flemming Kjær Jensen MunSic Jeong +Chris Jerdonek Jim Jewett Orjan Johansen Fredrik Johansson diff -r 61e6ac40c816 Misc/NEWS --- a/Misc/NEWS Thu Jul 05 20:57:33 2012 +0200 +++ b/Misc/NEWS Fri Jul 06 05:26:15 2012 -0700 @@ -23,6 +23,9 @@ Library ------- +- Issue #14649: Fixed the exception message when doctest.DocTestSuite is + passed a module containing no docstrings. + - Issue #15166: Implement imp.get_tag() using sys.implementation.cache_tag. - Issue #15210: Catch KeyError when imprortlib.__init__ can't find @@ -131,7 +134,7 @@ - Issue #15176: Clarified behavior, documentation, and implementation of os.listdir(). - + - Issue #15061: Re-implemented hmac.compare_digest() in C to prevent further timing analysis and to support all buffer protocol aware objects as well as ASCII only str instances safely.