summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Smith <eric@trueblade.com>2008-03-19 12:09:55 (GMT)
committerEric Smith <eric@trueblade.com>2008-03-19 12:09:55 (GMT)
commite50444597218da4fc9c7397c06e857125aa29d98 (patch)
tree9ea8f6802ea51c8b39ec45508f0cbe3cabe659a7
parent4f4738f015c5d16cac3440adfe40b4ac52ba2316 (diff)
downloadcpython-e50444597218da4fc9c7397c06e857125aa29d98.zip
cpython-e50444597218da4fc9c7397c06e857125aa29d98.tar.gz
cpython-e50444597218da4fc9c7397c06e857125aa29d98.tar.bz2
Use test.test_support.captured_stdout instead of a custom contextmanager.
Thanks Nick Coghlan.
-rw-r--r--Lib/test/test_print.py14
1 files changed, 1 insertions, 13 deletions
diff --git a/Lib/test/test_print.py b/Lib/test/test_print.py
index db09c9c..e9405c5 100644
--- a/Lib/test/test_print.py
+++ b/Lib/test/test_print.py
@@ -14,8 +14,6 @@ except ImportError:
# 2.x
from StringIO import StringIO
-from contextlib import contextmanager
-
NotDefined = object()
# A dispatch table all 8 combinations of providing
@@ -42,15 +40,6 @@ dispatch = {
lambda args, sep, end, file: print(sep=sep, end=end, file=file, *args),
}
-@contextmanager
-def stdout_redirected(new_stdout):
- save_stdout = sys.stdout
- sys.stdout = new_stdout
- try:
- yield None
- finally:
- sys.stdout = save_stdout
-
# Class used to test __str__ and print
class ClassWith__str__:
def __init__(self, x):
@@ -71,8 +60,7 @@ class TestPrint(unittest.TestCase):
end is not NotDefined,
file is not NotDefined)]
- t = StringIO()
- with stdout_redirected(t):
+ with test_support.captured_stdout() as t:
fn(args, sep, end, file)
self.assertEqual(t.getvalue(), expected)