diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2011-05-14 08:19:43 +0300 |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2011-05-14 08:19:43 +0300 |
commit | 84eadc8ce69ed90456c10807ae176656fd81c392 (patch) | |
tree | d379eba6eca19d812def559ad3d17f2a9e6d8ba9 | |
parent | 57534a7af2c74b84ab859373cd8ede12961aba0e (diff) | |
download | cpython-84eadc8ce69ed90456c10807ae176656fd81c392.tar.gz |
#7960: fix docstrings for captured_output and captured_stdout.
-rw-r--r-- | Lib/test/test_support.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index e237709366..81bb3ca017 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -814,14 +814,8 @@ def transient_internet(resource_name, timeout=30.0, errnos=()): @contextlib.contextmanager def captured_output(stream_name): - """Run the 'with' statement body using a StringIO object in place of a - specific attribute on the sys module. - Example use (with 'stream_name=stdout'):: - - with captured_stdout() as s: - print "hello" - assert s.getvalue() == "hello" - """ + """Return a context manager used by captured_stdout and captured_stdin + that temporarily replaces the sys stream *stream_name* with a StringIO.""" import StringIO orig_stdout = getattr(sys, stream_name) setattr(sys, stream_name, StringIO.StringIO()) @@ -831,6 +825,12 @@ 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_stdin(): |