summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_doctest.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2004-09-13 14:53:28 (GMT)
committerTim Peters <tim.peters@gmail.com>2004-09-13 14:53:28 (GMT)
commit958cc890370d58b81bf15177f0dfeecff8714394 (patch)
tree22e287543bc1eafb3fb19006fc05fcccf63d4684 /Lib/test/test_doctest.py
parent302bd589ad22481795a8a34eceb66dabcfd6a2d6 (diff)
downloadcpython-958cc890370d58b81bf15177f0dfeecff8714394.zip
cpython-958cc890370d58b81bf15177f0dfeecff8714394.tar.gz
cpython-958cc890370d58b81bf15177f0dfeecff8714394.tar.bz2
exclude_empty: make the default True for DocTestFinder, and introduce it
with default False for testmod(). The real point of introducing this was so that output from doctest.master.summarize() would be the same as in 2.3, and doctest.master in 2.4 is a backward-compatability hack used only by testmod().
Diffstat (limited to 'Lib/test/test_doctest.py')
-rw-r--r--Lib/test/test_doctest.py27
1 files changed, 20 insertions, 7 deletions
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index a304f5c..77b9ef5 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -377,8 +377,8 @@ By default, tests are created for objects with no docstring:
>>> def no_docstring(v):
... pass
- >>> finder.find(no_docstring) # doctest: +ELLIPSIS
- [<DocTest no_docstring from ... (no examples)>]
+ >>> finder.find(no_docstring)
+ []
However, the optional argument `exclude_empty` to the DocTestFinder
constructor can be used to exclude tests for objects with empty
@@ -414,8 +414,6 @@ methods, classmethods, staticmethods, properties, and nested classes.
1 SampleClass
3 SampleClass.NestedClass
1 SampleClass.NestedClass.__init__
- 0 SampleClass.NestedClass.get
- 0 SampleClass.NestedClass.square
1 SampleClass.__init__
2 SampleClass.a_classmethod
1 SampleClass.a_property
@@ -473,8 +471,6 @@ functions, classes, and the `__test__` dictionary, if it exists:
1 some_module.SampleClass
3 some_module.SampleClass.NestedClass
1 some_module.SampleClass.NestedClass.__init__
- 0 some_module.SampleClass.NestedClass.get
- 0 some_module.SampleClass.NestedClass.square
1 some_module.SampleClass.__init__
2 some_module.SampleClass.a_classmethod
1 some_module.SampleClass.a_property
@@ -520,6 +516,23 @@ deprecated isprivate gimmick.
1 SampleClass
3 SampleClass.NestedClass
1 SampleClass.NestedClass.__init__
+ 1 SampleClass.__init__
+ 1 SampleClass.double
+ 1 SampleClass.get
+
+By default, that excluded objects with no doctests. exclude_empty=False
+tells it to include (empty) tests for objects with no doctests. This feature
+is really to support backward compatibility in what doctest.master.summarize()
+displays.
+
+ >>> tests = doctest.DocTestFinder(_namefilter=namefilter,
+ ... exclude_empty=False).find(SampleClass)
+ >>> tests.sort()
+ >>> for t in tests:
+ ... print '%2s %s' % (len(t.examples), t.name)
+ 1 SampleClass
+ 3 SampleClass.NestedClass
+ 1 SampleClass.NestedClass.__init__
0 SampleClass.NestedClass.get
0 SampleClass.NestedClass.square
1 SampleClass.__init__
@@ -550,7 +563,7 @@ object explicitly passed to DocTestFinder:
... return base == 'SampleClass'
>>> tests = doctest.DocTestFinder(_namefilter=namefilter).find(SampleClass)
>>> len(tests)
- 11
+ 9
Turning off Recursion
~~~~~~~~~~~~~~~~~~~~~