mirror of
https://github.com/python/cpython.git
synced 2025-09-14 04:37:29 +00:00
(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.
This commit is contained in:
commit
e6db1440d8
1 changed files with 12 additions and 19 deletions
|
@ -33,26 +33,19 @@ from test import test_doctest, sample_doctest
|
||||||
|
|
||||||
|
|
||||||
def _run_object_doctest(obj, module):
|
def _run_object_doctest(obj, module):
|
||||||
# Direct doctest output (normally just errors) to real stdout; doctest
|
finder = doctest.DocTestFinder(verbose=verbose, recurse=False)
|
||||||
# output shouldn't be compared by regrtest.
|
runner = doctest.DocTestRunner(verbose=verbose)
|
||||||
save_stdout = sys.stdout
|
# Use the object's fully qualified name if it has one
|
||||||
sys.stdout = test.support.get_original_stdout()
|
# Otherwise, use the module's name
|
||||||
try:
|
try:
|
||||||
finder = doctest.DocTestFinder(verbose=verbose, recurse=False)
|
name = "%s.%s" % (obj.__module__, obj.__name__)
|
||||||
runner = doctest.DocTestRunner(verbose=verbose)
|
except AttributeError:
|
||||||
# Use the object's fully qualified name if it has one
|
name = module.__name__
|
||||||
# Otherwise, use the module's name
|
for example in finder.find(obj, name, module):
|
||||||
try:
|
runner.run(example)
|
||||||
name = "%s.%s" % (obj.__module__, obj.__name__)
|
f, t = runner.failures, runner.tries
|
||||||
except AttributeError:
|
if f:
|
||||||
name = module.__name__
|
raise test.support.TestFailed("%d of %d doctests failed" % (f, t))
|
||||||
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
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print ('doctest (%s) ... %d tests with zero failures' % (module.__name__, t))
|
print ('doctest (%s) ... %d tests with zero failures' % (module.__name__, t))
|
||||||
return f, t
|
return f, t
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue