From: Ezio Melotti Date: Sat, 14 May 2011 05:43:25 +0000 (+0300) Subject: #7960: merge with 3.1. X-Git-Tag: v3.3.0a1~2283^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e728d72d8afba6f5dde330f99e7a336f183122eb;p=thirdparty%2FPython%2Fcpython.git #7960: merge with 3.1. --- e728d72d8afba6f5dde330f99e7a336f183122eb diff --cc Lib/test/support.py index bd35fded3567,b3b1bbdc2d34..b1ca9ddebf96 --- a/Lib/test/support.py +++ b/Lib/test/support.py @@@ -908,14 -723,14 +902,20 @@@ def captured_output(stream_name) setattr(sys, stream_name, orig_stdout) def captured_stdout(): + """Capture the output of sys.stdout: + + with captured_stdout() as s: + print("hello") + self.assertEqual(s.getvalue(), "hello") + """ return captured_output("stdout") +def captured_stderr(): + return captured_output("stderr") + +def captured_stdin(): + return captured_output("stdin") + def gc_collect(): """Force as many objects as possible to be collected.