make test_support's captured_output a bit more robust when exceptions happen
This commit is contained in:
parent
63b0a2eb21
commit
d8f2d0bdb3
|
@ -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…
Reference in New Issue