diff options
author | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-12-30 19:36:29 (GMT) |
---|---|---|
committer | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-12-30 19:36:29 (GMT) |
commit | 6f17e2df29a865a29447531e89fb22be710e382d (patch) | |
tree | 62c939a3e7eee02f8f6372dac306c9af93f4945a /Lib/unittest/test | |
parent | 30baf2b0eda97fa8a36fddc81824b5772d764018 (diff) | |
download | cpython-6f17e2df29a865a29447531e89fb22be710e382d.zip cpython-6f17e2df29a865a29447531e89fb22be710e382d.tar.gz cpython-6f17e2df29a865a29447531e89fb22be710e382d.tar.bz2 |
Issue 10786: unittest.TextTestRunner default stream no longer bound at import time
Diffstat (limited to 'Lib/unittest/test')
-rw-r--r-- | Lib/unittest/test/test_runner.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/unittest/test/test_runner.py b/Lib/unittest/test/test_runner.py index 8f98a02..8e95410 100644 --- a/Lib/unittest/test/test_runner.py +++ b/Lib/unittest/test/test_runner.py @@ -299,3 +299,20 @@ class Test_TextTestRunner(unittest.TestCase): self.assertEqual(out.count(msg), 3) for msg in [ae_msg, at_msg]: self.assertEqual(out.count(msg), 1) + + def testStdErrLookedUpAtInstantiationTime(self): + # see issue 10786 + old_stderr = sys.stderr + f = io.StringIO() + sys.stderr = f + try: + runner = unittest.TextTestRunner() + self.assertTrue(runner.stream.stream is f) + finally: + sys.stderr = old_stderr + + def testSpecifiedStreamUsed(self): + # see issue 10786 + f = io.StringIO() + runner = unittest.TextTestRunner(f) + self.assertTrue(runner.stream.stream is f) |