summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_support.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-09-21 20:31:52 (GMT)
committerGuido van Rossum <guido@python.org>2001-09-21 20:31:52 (GMT)
commit0fcca4e815e3dbb28c73108376079a94ad6ee8de (patch)
tree7c41c199c52d4d59d53a8ac3e54a1bed1c64926b /Lib/test/test_support.py
parent867a8d2e2688d837c67bf87eb9164528780f7bdc (diff)
downloadcpython-0fcca4e815e3dbb28c73108376079a94ad6ee8de.zip
cpython-0fcca4e815e3dbb28c73108376079a94ad6ee8de.tar.gz
cpython-0fcca4e815e3dbb28c73108376079a94ad6ee8de.tar.bz2
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 d2a485f..0a96f66 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))