diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2024-02-04 15:27:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-04 15:27:42 (GMT) |
commit | ecabff98c41453f15ecd26ac255d531b571b9bc1 (patch) | |
tree | 901c196e66150cc59acbab36d7906bf603c6966e /Lib/unittest | |
parent | ca715e56a13feabc15c368898df6511613d18987 (diff) | |
download | cpython-ecabff98c41453f15ecd26ac255d531b571b9bc1.zip cpython-ecabff98c41453f15ecd26ac255d531b571b9bc1.tar.gz cpython-ecabff98c41453f15ecd26ac255d531b571b9bc1.tar.bz2 |
gh-113267: Revert "gh-106584: Fix exit code for unittest in Python 3.12 (#106588)" (GH-114470)
This reverts commit 8fc071345b50dd3de61ebeeaa287ccef21d061b2.
Diffstat (limited to 'Lib/unittest')
-rw-r--r-- | Lib/unittest/case.py | 4 | ||||
-rw-r--r-- | Lib/unittest/result.py | 10 |
2 files changed, 5 insertions, 9 deletions
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py index 8115574..001b640 100644 --- a/Lib/unittest/case.py +++ b/Lib/unittest/case.py @@ -606,6 +606,7 @@ class TestCase(object): else: stopTestRun = None + result.startTest(self) try: testMethod = getattr(self, self._testMethodName) if (getattr(self.__class__, "__unittest_skip__", False) or @@ -616,9 +617,6 @@ class TestCase(object): _addSkip(result, self, skip_why) return result - # Increase the number of tests only if it hasn't been skipped - result.startTest(self) - expecting_failure = ( getattr(self, "__unittest_expecting_failure__", False) or getattr(testMethod, "__unittest_expecting_failure__", False) diff --git a/Lib/unittest/result.py b/Lib/unittest/result.py index 9e56f65..3ace0a5 100644 --- a/Lib/unittest/result.py +++ b/Lib/unittest/result.py @@ -97,12 +97,10 @@ class TestResult(object): sys.stdout = self._original_stdout sys.stderr = self._original_stderr - if self._stdout_buffer is not None: - self._stdout_buffer.seek(0) - self._stdout_buffer.truncate() - if self._stderr_buffer is not None: - self._stderr_buffer.seek(0) - self._stderr_buffer.truncate() + self._stdout_buffer.seek(0) + self._stdout_buffer.truncate() + self._stderr_buffer.seek(0) + self._stderr_buffer.truncate() def stopTestRun(self): """Called once after all tests are executed. |