mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Issue 10786: unittest.TextTestRunner default stream no longer bound at import time
This commit is contained in:
parent
30baf2b0ed
commit
6f17e2df29
3 changed files with 24 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue