diff options
| author | Michael Foord <michael@python.org> | 2011-03-17 16:48:56 (GMT) |
|---|---|---|
| committer | Michael Foord <michael@python.org> | 2011-03-17 16:48:56 (GMT) |
| commit | 8faa20751d893443e6927c4e18c1cd0b26455994 (patch) | |
| tree | 646bb85e175de3469e79f57a63e2c0944bdaa07c /Lib/unittest/result.py | |
| parent | 5a9a5080cf26712160efa79e932e2eeca59437bc (diff) | |
| download | cpython-8faa20751d893443e6927c4e18c1cd0b26455994.zip cpython-8faa20751d893443e6927c4e18c1cd0b26455994.tar.gz cpython-8faa20751d893443e6927c4e18c1cd0b26455994.tar.bz2 | |
Issue #10979. unittest stdout buffering now works for class and module fixtures.
Diffstat (limited to 'Lib/unittest/result.py')
| -rw-r--r-- | Lib/unittest/result.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/unittest/result.py b/Lib/unittest/result.py index 1f66f1b..2cc17d7 100644 --- a/Lib/unittest/result.py +++ b/Lib/unittest/result.py @@ -60,6 +60,9 @@ class TestResult(object): "Called when the given test is about to be run" self.testsRun += 1 self._mirrorOutput = False + self._setupStdout() + + def _setupStdout(self): if self.buffer: if self._stderr_buffer is None: self._stderr_buffer = StringIO() @@ -75,6 +78,10 @@ class TestResult(object): def stopTest(self, test): """Called when the given test has been run""" + self._restoreStdout() + self._mirrorOutput = False + + def _restoreStdout(self): if self.buffer: if self._mirrorOutput: output = sys.stdout.getvalue() @@ -94,7 +101,6 @@ class TestResult(object): self._stdout_buffer.truncate() self._stderr_buffer.seek(0) self._stderr_buffer.truncate() - self._mirrorOutput = False def stopTestRun(self): """Called once after all tests are executed. |
