summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2004-09-13 00:52:51 (GMT)
committerTim Peters <tim.peters@gmail.com>2004-09-13 00:52:51 (GMT)
commit82076ef19482c7fc8b3f4a322f12d4417a397b3e (patch)
tree76b68999b39e0f1f42c3b6dd4e22ac26c6c17bdf /Lib
parent9661f9ab4f969651e7f1fea224034237e328f6ac (diff)
downloadcpython-82076ef19482c7fc8b3f4a322f12d4417a397b3e.zip
cpython-82076ef19482c7fc8b3f4a322f12d4417a397b3e.tar.gz
cpython-82076ef19482c7fc8b3f4a322f12d4417a397b3e.tar.bz2
Reluctantly, rehabilitate doctest.master.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/doctest.py35
1 files changed, 26 insertions, 9 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py
index 5d371d2..3a8496f 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -1531,6 +1531,20 @@ class DocTestRunner:
print "Test passed."
return totalf, totalt
+ #/////////////////////////////////////////////////////////////////
+ # Backward compatibility cruft to maintain doctest.master.
+ #/////////////////////////////////////////////////////////////////
+ def merge(self, other):
+ d = self._name2ft
+ for name, (f, t) in other._name2ft.items():
+ if name in d:
+ print "*** DocTestRunner.merge: '" + name + "' in both" \
+ " testers; summing outcomes."
+ f2, t2 = d[name]
+ f = f + f2
+ t = t + t2
+ d[name] = f, t
+
class OutputChecker:
"""
A class used to check the whether the actual output from a doctest
@@ -1810,6 +1824,10 @@ class DebugRunner(DocTestRunner):
######################################################################
# These should be backwards compatible.
+# For backward compatibility, a global instance of a DocTestRunner
+# class, updated by testmod.
+master = None
+
def testmod(m=None, name=None, globs=None, verbose=None, isprivate=None,
report=True, optionflags=0, extraglobs=None,
raise_on_error=False):
@@ -1883,6 +1901,8 @@ def testmod(m=None, name=None, globs=None, verbose=None, isprivate=None,
displaying a summary. Invoke doctest.master.summarize(verbose)
when you're done fiddling.
"""
+ global master
+
if isprivate is not None:
warnings.warn("the isprivate argument is deprecated; "
"examine DocTestFinder.find() lists instead",
@@ -1917,6 +1937,11 @@ def testmod(m=None, name=None, globs=None, verbose=None, isprivate=None,
if report:
runner.summarize()
+ if master is None:
+ master = runner
+ else:
+ master.merge(runner)
+
return runner.failures, runner.tries
def run_docstring_examples(f, globs, verbose=False, name="NoName",
@@ -2007,15 +2032,7 @@ class Tester:
return self.testrunner.summarize(verbose)
def merge(self, other):
- d = self.testrunner._name2ft
- for name, (f, t) in other.testrunner._name2ft.items():
- if name in d:
- print "*** Tester.merge: '" + name + "' in both" \
- " testers; summing outcomes."
- f2, t2 = d[name]
- f = f + f2
- t = t + t2
- d[name] = f, t
+ self.testrunner.merge(other.testrunner)
######################################################################
## 8. Unittest Support