diff options
| author | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-04-07 23:04:22 (GMT) |
|---|---|---|
| committer | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-04-07 23:04:22 (GMT) |
| commit | f6ff26c486373dcb6c9ee2f4aae102202e89b722 (patch) | |
| tree | cf9bae379f6535622a28b261b68e0291bfe38450 /Lib/unittest/result.py | |
| parent | 9a39eccfe168a1ce86197aca0a5cd1de67aa1589 (diff) | |
| download | cpython-f6ff26c486373dcb6c9ee2f4aae102202e89b722.zip cpython-f6ff26c486373dcb6c9ee2f4aae102202e89b722.tar.gz cpython-f6ff26c486373dcb6c9ee2f4aae102202e89b722.tar.bz2 | |
unittest.result.TestResult does not create its buffers until they're used. It uses StringIO not cStringIO. Issue 8333.
Diffstat (limited to 'Lib/unittest/result.py')
| -rw-r--r-- | Lib/unittest/result.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/unittest/result.py b/Lib/unittest/result.py index b9045f4..4b7cde6 100644 --- a/Lib/unittest/result.py +++ b/Lib/unittest/result.py @@ -4,7 +4,7 @@ import os import sys import traceback -from cStringIO import StringIO +from StringIO import StringIO from . import util from functools import wraps @@ -46,8 +46,8 @@ class TestResult(object): self.unexpectedSuccesses = [] self.shouldStop = False self.buffer = False - self._stdout_buffer = StringIO() - self._stderr_buffer = StringIO() + self._stdout_buffer = None + self._stderr_buffer = None self._original_stdout = sys.stdout self._original_stderr = sys.stderr self._mirrorOutput = False @@ -60,6 +60,9 @@ class TestResult(object): self.testsRun += 1 self._mirrorOutput = False if self.buffer: + if self._stderr_buffer is None: + self._stderr_buffer = StringIO() + self._stdout_buffer = StringIO() sys.stdout = self._stdout_buffer sys.stderr = self._stderr_buffer |
