Commits

Victor Stinner committed bc2f3fb

Issue #12400: test_zipimport_support doesn't restore original sys.stdout
anymore

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

Comments (0)

Files changed (1)

Lib/test/test_zipimport_support.py

 
 
 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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.