[3.12] gh-106584: Fix exit code for unittest in Python 3.12 (GH-106588) (#109725)

gh-106584: Fix exit code for unittest in Python 3.12 (GH-106588)
(cherry picked from commit 8fc071345b)

Co-authored-by: EliseevEgor <egor.eliseev@jetbrains.com>
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
Miss Islington (bot) 2023-10-02 08:18:41 -07:00 committed by GitHub
parent 84ef145d85
commit 551aa6ab94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 12 deletions

View file

@ -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)