mirror of
https://github.com/python/cpython.git
synced 2026-03-24 21:51:12 +00:00
make test_support's captured_output a bit more robust when exceptions happen
This commit is contained in:
parent
63b0a2eb21
commit
d8f2d0bdb3
1 changed files with 4 additions and 2 deletions
|
|
@ -482,8 +482,10 @@ def captured_output(stream_name):
|
|||
import StringIO
|
||||
orig_stdout = getattr(sys, stream_name)
|
||||
setattr(sys, stream_name, StringIO.StringIO())
|
||||
yield getattr(sys, stream_name)
|
||||
setattr(sys, stream_name, orig_stdout)
|
||||
try:
|
||||
yield getattr(sys, stream_name)
|
||||
finally:
|
||||
setattr(sys, stream_name, orig_stdout)
|
||||
|
||||
def captured_stdout():
|
||||
return captured_output("stdout")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue