Skip to content

Commit 2ff85d7

Browse files
author
benjamin.peterson
committed
make test_support's captured_output a bit more robust when exceptions happen
git-svn-id: http://svn.python.org/projects/python/trunk@62604 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 5aca2bb commit 2ff85d7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Lib/test/test_support.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,10 @@ def captured_output(stream_name):
482482
import StringIO
483483
orig_stdout = getattr(sys, stream_name)
484484
setattr(sys, stream_name, StringIO.StringIO())
485-
yield getattr(sys, stream_name)
486-
setattr(sys, stream_name, orig_stdout)
485+
try:
486+
yield getattr(sys, stream_name)
487+
finally:
488+
setattr(sys, stream_name, orig_stdout)
487489

488490
def captured_stdout():
489491
return captured_output("stdout")

0 commit comments

Comments
 (0)