summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_contextlib.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2013-10-10 07:46:57 (GMT)
committerRaymond Hettinger <python@rcn.com>2013-10-10 07:46:57 (GMT)
commit088cbf2d390f6caeb021f05909e1d0b2e506b332 (patch)
tree0e89ef127f2bdec4e01aa001b23bf6af2ff140b6 /Lib/test/test_contextlib.py
parent5ed3bc9adbb5af56450b918410bf07b2bf54ef54 (diff)
downloadcpython-088cbf2d390f6caeb021f05909e1d0b2e506b332.zip
cpython-088cbf2d390f6caeb021f05909e1d0b2e506b332.tar.gz
cpython-088cbf2d390f6caeb021f05909e1d0b2e506b332.tar.bz2
Issue #15805: Add contextlib.redirect_stdout()
Diffstat (limited to 'Lib/test/test_contextlib.py')
-rw-r--r--Lib/test/test_contextlib.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_contextlib.py b/Lib/test/test_contextlib.py
index 2892917..d8a0530 100644
--- a/Lib/test/test_contextlib.py
+++ b/Lib/test/test_contextlib.py
@@ -1,5 +1,6 @@
"""Unit tests for contextlib.py, and other context managers."""
+import io
import sys
import tempfile
import unittest
@@ -653,6 +654,14 @@ class TestIgnored(unittest.TestCase):
with ignored(LookupError):
'Hello'[50]
+class TestRedirectStdout(unittest.TestCase):
+
+ def test_redirect_to_string_io(self):
+ f = io.StringIO()
+ with redirect_stdout(f):
+ help(pow)
+ s = f.getvalue()
+ self.assertIn('pow', s)
if __name__ == "__main__":
unittest.main()