diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-04-30 21:03:58 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-04-30 21:03:58 (GMT) |
commit | d8f2d0bdb3d3b9abe53cda9add979e2fc4be7da0 (patch) | |
tree | 759ee7606ebe295ce95b1321f3cc921dd9e849bd /Lib/test/test_support.py | |
parent | 63b0a2eb21386e1c6b1e5d97421085d543150c2c (diff) | |
download | cpython-d8f2d0bdb3d3b9abe53cda9add979e2fc4be7da0.zip cpython-d8f2d0bdb3d3b9abe53cda9add979e2fc4be7da0.tar.gz cpython-d8f2d0bdb3d3b9abe53cda9add979e2fc4be7da0.tar.bz2 |
make test_support's captured_output a bit more robust when exceptions happen
Diffstat (limited to 'Lib/test/test_support.py')
-rw-r--r-- | Lib/test/test_support.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index 6f739af..04a0ab8 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -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") |