diff options
Diffstat (limited to 'Lib/test/test_support.py')
-rw-r--r-- | Lib/test/test_support.py | 28 |
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)) |