summaryrefslogtreecommitdiff
path: root/Lib/test/test_support.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-09-21 20:31:52 +0000
committerGuido van Rossum <guido@python.org>2001-09-21 20:31:52 +0000
commit519d0ce78a5a80c2bdceee54f464742af77e3fe2 (patch)
treef97ec660f89eedeeac117a29947b01589e08797a /Lib/test/test_support.py
parent7cf12509b648d23dba4f95c38ca8a73e2a9821ea (diff)
downloadcpython-519d0ce78a5a80c2bdceee54f464742af77e3fe2.tar.gz
Change the way unexpected output is reported: rather than stopping at
the first difference, let the test run till completion, then gather all the output and compare it to the expected output using difflib. XXX Still to do: produce diff output that only shows the sections that differ; currently it produces ndiff-style output because that's the easiest to produce with difflib, but this becomes a liability when the output is voluminous and there are only a few differences.
Diffstat (limited to 'Lib/test/test_support.py')
-rw-r--r--Lib/test/test_support.py28
1 files changed, 12 insertions, 16 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index d2a485f73b..0a96f66567 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -23,23 +23,22 @@ use_resources = None # Flag set to [] by regrtest.py
# _output_comparison controls whether regrtest will try to compare stdout
# with an expected-output file. For straight regrtests, it should.
-# The doctest driver should set_output_comparison(0) for the duration, and
-# restore the old value when it's done.
+# The doctest driver resets this flag by calling deny_output_comparison().
# Note that this control is in addition to verbose mode: output will be
# compared if and only if _output_comparison is true and verbose mode is
# not in effect.
_output_comparison = 1
-def set_output_comparison(newvalue):
+def deny_output_comparison():
global _output_comparison
- oldvalue = _output_comparison
- _output_comparison = newvalue
- return oldvalue
+ _output_comparison = 0
# regrtest's interface to _output_comparison.
-def suppress_output_comparison():
- return not _output_comparison
-
+def output_comparison_denied():
+ global _output_comparison
+ denied = not _output_comparison
+ _output_comparison = 1
+ return denied
def unload(name):
try:
@@ -199,10 +198,7 @@ def run_doctest(module, verbosity=None):
else:
verbosity = None
- oldvalue = set_output_comparison(0)
- try:
- f, t = doctest.testmod(module, verbose=verbosity)
- if f:
- raise TestFailed("%d of %d doctests failed" % (f, t))
- finally:
- set_output_comparison(oldvalue)
+ deny_output_comparison()
+ f, t = doctest.testmod(module, verbose=verbosity)
+ if f:
+ raise TestFailed("%d of %d doctests failed" % (f, t))