summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_doctest.py
diff options
context:
space:
mode:
authorZachary Ware <zachary.ware@gmail.com>2013-11-24 08:21:57 (GMT)
committerZachary Ware <zachary.ware@gmail.com>2013-11-24 08:21:57 (GMT)
commit7119b454fddcf0429b0ece4d18f747eb7ae6fe61 (patch)
tree464319f5265a932e9bfb42bc6c5d2c0f23523e7b /Lib/test/test_doctest.py
parentfe94d8adfcf146af7531a315092e3ae954b68968 (diff)
downloadcpython-7119b454fddcf0429b0ece4d18f747eb7ae6fe61.zip
cpython-7119b454fddcf0429b0ece4d18f747eb7ae6fe61.tar.gz
cpython-7119b454fddcf0429b0ece4d18f747eb7ae6fe61.tar.bz2
Issue #3158: Relax new doctests a bit.
Apparently, the number of objects with docstrings in builtins varies with --with-pydebug (non-debug has one fewer). Also, skip the new tests entirely if built --without-doc-strings.
Diffstat (limited to 'Lib/test/test_doctest.py')
-rw-r--r--Lib/test/test_doctest.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index d99a16a..5b53ca8 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -409,7 +409,8 @@ Compare `DocTestCase`:
"""
-def test_DocTestFinder(): r"""
+class test_DocTestFinder:
+ def basics(): r"""
Unit tests for the `DocTestFinder` class.
DocTestFinder is used to extract DocTests from an object's docstring
@@ -644,6 +645,10 @@ DocTestFinder finds the line number of each example:
>>> test = doctest.DocTestFinder().find(f)[0]
>>> [e.lineno for e in test.examples]
[1, 9, 12]
+"""
+
+ if int.__doc__: # simple check for --without-doc-strings, skip if lacking
+ def non_Python_modules(): r"""
Finding Doctests in Modules Not Written in Python
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -653,10 +658,10 @@ plain ol' Python and is guaranteed to be available.
>>> import builtins
>>> tests = doctest.DocTestFinder().find(builtins)
- >>> len(tests) # how many objects checked for doctests
- 794
+ >>> 790 < len(tests) < 800 # approximate number of objects with docstrings
+ True
>>> real_tests = [t for t in tests if len(t.examples) > 0]
- >>> len(real_tests) # how many objects actually have doctests
+ >>> len(real_tests) # objects that actually have doctests
8
>>> for t in real_tests:
... print('{} {}'.format(len(t.examples), t.name))