mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #15805: Add contextlib.redirect_stdout()
This commit is contained in:
parent
5ed3bc9adb
commit
088cbf2d39
4 changed files with 81 additions and 1 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue