Issue 10786: unittest.TextTestRunner default stream no longer bound at import time

This commit is contained in:
Michael Foord 2010-12-30 19:36:29 +00:00
parent 30baf2b0ed
commit 6f17e2df29
3 changed files with 24 additions and 1 deletions

View file

@ -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)