mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
gh-106584: Fix exit code for unittest in Python 3.12 (#106588)
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com> Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
parent
34ddcc3fa1
commit
8fc071345b
5 changed files with 18 additions and 12 deletions
|
|
@ -606,7 +606,6 @@ class TestCase(object):
|
|||
else:
|
||||
stopTestRun = None
|
||||
|
||||
result.startTest(self)
|
||||
try:
|
||||
testMethod = getattr(self, self._testMethodName)
|
||||
if (getattr(self.__class__, "__unittest_skip__", False) or
|
||||
|
|
@ -617,6 +616,9 @@ 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)
|
||||
|
|
|
|||
|
|
@ -97,10 +97,12 @@ class TestResult(object):
|
|||
|
||||
sys.stdout = self._original_stdout
|
||||
sys.stderr = self._original_stderr
|
||||
self._stdout_buffer.seek(0)
|
||||
self._stdout_buffer.truncate()
|
||||
self._stderr_buffer.seek(0)
|
||||
self._stderr_buffer.truncate()
|
||||
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()
|
||||
|
||||
def stopTestRun(self):
|
||||
"""Called once after all tests are executed.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue