]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#7960: merge with 3.1.
authorEzio Melotti <ezio.melotti@gmail.com>
Sat, 14 May 2011 05:43:25 +0000 (08:43 +0300)
committerEzio Melotti <ezio.melotti@gmail.com>
Sat, 14 May 2011 05:43:25 +0000 (08:43 +0300)
1  2 
Lib/test/support.py

index bd35fded3567d0b176b4134030ab8654b00bc27b,b3b1bbdc2d349526990dfe8ee536dbe4814d5eaf..b1ca9ddebf968ef8ad31ec5198a1368188acc719
@@@ -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.