diff -r 39e0be9106c1 Lib/test/support.py --- a/Lib/test/support.py Sun May 26 18:57:00 2013 -0700 +++ b/Lib/test/support.py Mon May 27 20:44:46 2013 +0300 @@ -1181,14 +1181,26 @@ with captured_stdout() as s: print("hello") - self.assertEqual(s.getvalue(), "hello") + self.assertEqual(s.getvalue(), "hello\n") """ return captured_output("stdout") def captured_stderr(): + """Capture the output of sys.stderr: + + with captured_stderr() as s: + print("hello", file=sys.stderr) + self.assertEqual(s.getvalue(), "hello\n") + """ return captured_output("stderr") def captured_stdin(): + """Capture the input of sys.stdin: + + with captured_stdin() as s: + print("hello", file=sys.stdin) + self.assertEqual(s.getvalue(), "hello\n") + """ return captured_output("stdin")