summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2004-08-08 01:48:59 (GMT)
committerTim Peters <tim.peters@gmail.com>2004-08-08 01:48:59 (GMT)
commitf727c6c2c7e608368fd1514ab46b1ed87ba57baf (patch)
tree3aa4be86e50caa08808d71065da6b2711b7c4529 /Lib/test
parent9ca3f8551a3b3aede874fa926d82f1dd9fd41754 (diff)
downloadcpython-f727c6c2c7e608368fd1514ab46b1ed87ba57baf.zip
cpython-f727c6c2c7e608368fd1514ab46b1ed87ba57baf.tar.gz
cpython-f727c6c2c7e608368fd1514ab46b1ed87ba57baf.tar.bz2
Deprecated testmod's useless & confusing isprivate gimmick.
Ripped out the docs for the new DocTestFinder's namefilter argument, and renamed it to _namefilter; this only existed to support isprivate. Removed the new DocTestFinder's objfilter argument. No point adding more cruft to a broken filtering design.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_doctest.py29
1 files changed, 8 insertions, 21 deletions
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index 717771d..886da3f 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -387,12 +387,13 @@ will only be generated for it once:
Filter Functions
~~~~~~~~~~~~~~~~
-Two filter functions can be used to restrict which objects get
-examined: a name-based filter and an object-based filter.
+A filter function can be used to restrict which objects get examined,
+but this is temporary, undocumented internal support for testmod's
+deprecated isprivate gimmick.
>>> def namefilter(prefix, base):
... return base.startswith('a_')
- >>> tests = doctest.DocTestFinder(namefilter=namefilter).find(SampleClass)
+ >>> tests = doctest.DocTestFinder(_namefilter=namefilter).find(SampleClass)
>>> tests.sort()
>>> for t in tests:
... print '%2s %s' % (len(t.examples), t.name)
@@ -403,26 +404,12 @@ examined: a name-based filter and an object-based filter.
1 SampleClass.double
1 SampleClass.get
- >>> def objfilter(obj):
- ... return isinstance(obj, (staticmethod, classmethod))
- >>> tests = doctest.DocTestFinder(objfilter=objfilter).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__
- 1 SampleClass.__init__
- 1 SampleClass.a_property
- 1 SampleClass.double
- 1 SampleClass.get
-
If a given object is filtered out, then none of the objects that it
contains will be added either:
>>> def namefilter(prefix, base):
... return base == 'NestedClass'
- >>> tests = doctest.DocTestFinder(namefilter=namefilter).find(SampleClass)
+ >>> tests = doctest.DocTestFinder(_namefilter=namefilter).find(SampleClass)
>>> tests.sort()
>>> for t in tests:
... print '%2s %s' % (len(t.examples), t.name)
@@ -434,12 +421,12 @@ contains will be added either:
1 SampleClass.double
1 SampleClass.get
-The filter functions apply to contained objects, and *not* to the
+The filter function apply to contained objects, and *not* to the
object explicitly passed to DocTestFinder:
>>> def namefilter(prefix, base):
... return base == 'SampleClass'
- >>> tests = doctest.DocTestFinder(namefilter=namefilter).find(SampleClass)
+ >>> tests = doctest.DocTestFinder(_namefilter=namefilter).find(SampleClass)
>>> len(tests)
9
@@ -1066,7 +1053,7 @@ def test_DocTestSuite():
poorly conceived, and will go away someday.
>>> finder = doctest.DocTestFinder(
- ... namefilter=lambda prefix, base: base!='bar')
+ ... _namefilter=lambda prefix, base: base!='bar')
>>> suite = doctest.DocTestSuite('test.sample_doctest',
... test_finder=finder)
>>> suite.run(unittest.TestResult())