[Python-checkins] cpython (merge 3.2 -> default): (merge 3.2) Issue #12400: test_zipimport_support doesn't restore original

victor.stinner python-checkins at python.org
Wed Jun 29 18:12:59 CEST 2011


http://hg.python.org/cpython/rev/ff5abf93db80
changeset:   71079:ff5abf93db80
parent:      71077:fc831c49216d
parent:      71078:bc2f3fbda7e3
user:        Victor Stinner <victor.stinner at haypocalc.com>
date:        Wed Jun 29 18:12:33 2011 +0200
summary:
  (merge 3.2) Issue #12400: test_zipimport_support doesn't restore original
sys.stdout anymore

regrtest doesn't check that a test doesn't output anything anymore.

files:
  Lib/test/test_zipimport_support.py |  31 ++++++-----------
  1 files changed, 12 insertions(+), 19 deletions(-)


diff --git a/Lib/test/test_zipimport_support.py b/Lib/test/test_zipimport_support.py
--- a/Lib/test/test_zipimport_support.py
+++ b/Lib/test/test_zipimport_support.py
@@ -33,26 +33,19 @@
 
 
 def _run_object_doctest(obj, module):
-    # Direct doctest output (normally just errors) to real stdout; doctest
-    # output shouldn't be compared by regrtest.
-    save_stdout = sys.stdout
-    sys.stdout = test.support.get_original_stdout()
+    finder = doctest.DocTestFinder(verbose=verbose, recurse=False)
+    runner = doctest.DocTestRunner(verbose=verbose)
+    # Use the object's fully qualified name if it has one
+    # Otherwise, use the module's name
     try:
-        finder = doctest.DocTestFinder(verbose=verbose, recurse=False)
-        runner = doctest.DocTestRunner(verbose=verbose)
-        # Use the object's fully qualified name if it has one
-        # Otherwise, use the module's name
-        try:
-            name = "%s.%s" % (obj.__module__, obj.__name__)
-        except AttributeError:
-            name = module.__name__
-        for example in finder.find(obj, name, module):
-            runner.run(example)
-        f, t = runner.failures, runner.tries
-        if f:
-            raise test.support.TestFailed("%d of %d doctests failed" % (f, t))
-    finally:
-        sys.stdout = save_stdout
+        name = "%s.%s" % (obj.__module__, obj.__name__)
+    except AttributeError:
+        name = module.__name__
+    for example in finder.find(obj, name, module):
+        runner.run(example)
+    f, t = runner.failures, runner.tries
+    if f:
+        raise test.support.TestFailed("%d of %d doctests failed" % (f, t))
     if verbose:
         print ('doctest (%s) ... %d tests with zero failures' % (module.__name__, t))
     return f, t

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list