Kaydet (Commit) 6f17e2df authored tarafından Michael Foord's avatar Michael Foord

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

üst 30baf2b0
...@@ -125,8 +125,10 @@ class TextTestRunner(object): ...@@ -125,8 +125,10 @@ class TextTestRunner(object):
""" """
resultclass = TextTestResult resultclass = TextTestResult
def __init__(self, stream=sys.stderr, descriptions=True, verbosity=1, def __init__(self, stream=None, descriptions=True, verbosity=1,
failfast=False, buffer=False, resultclass=None, warnings=None): failfast=False, buffer=False, resultclass=None, warnings=None):
if stream is None:
stream = sys.stderr
self.stream = _WritelnDecorator(stream) self.stream = _WritelnDecorator(stream)
self.descriptions = descriptions self.descriptions = descriptions
self.verbosity = verbosity self.verbosity = verbosity
......
...@@ -299,3 +299,20 @@ class Test_TextTestRunner(unittest.TestCase): ...@@ -299,3 +299,20 @@ class Test_TextTestRunner(unittest.TestCase):
self.assertEqual(out.count(msg), 3) self.assertEqual(out.count(msg), 3)
for msg in [ae_msg, at_msg]: for msg in [ae_msg, at_msg]:
self.assertEqual(out.count(msg), 1) 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)
...@@ -20,6 +20,10 @@ Core and Builtins ...@@ -20,6 +20,10 @@ Core and Builtins
Library Library
------- -------
- Issue 10786: unittest.TextTestRunner default stream no longer bound at
import time. `sys.stderr` now looked up at instantiation time. Fix contributed
by Mark Roddy.
- Issue 10753 - Characters ';','=' and ',' in the PATH_INFO environment - Issue 10753 - Characters ';','=' and ',' in the PATH_INFO environment
variable won't be quoted when the URI is constructed by the wsgiref.util 's variable won't be quoted when the URI is constructed by the wsgiref.util 's
request_uri method. According to RFC 3986, these characters can be a part of request_uri method. According to RFC 3986, these characters can be a part of
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment