summaryrefslogtreecommitdiffstats
path: root/Lib/unittest
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2022-11-22 15:49:37 (GMT)
committerGitHub <noreply@github.com>2022-11-22 15:49:37 (GMT)
commitc2102136be569e6fc8ed90181f229b46d07142f8 (patch)
tree9cbba443b73dfc3732f9ea135f34ff8dd5ac42ca /Lib/unittest
parentd15b9f19ac0ffb29b646735d69b29f48a71c247f (diff)
downloadcpython-c2102136be569e6fc8ed90181f229b46d07142f8.zip
cpython-c2102136be569e6fc8ed90181f229b46d07142f8.tar.gz
cpython-c2102136be569e6fc8ed90181f229b46d07142f8.tar.bz2
gh-99645: Fix a bug in handling class cleanups in unittest.TestCase (GH-99646)
Now addClassCleanup() uses separate lists for different TestCase subclasses, and doClassCleanups() only cleans up the particular class.
Diffstat (limited to 'Lib/unittest')
-rw-r--r--Lib/unittest/case.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py
index b01f660..5167c5f 100644
--- a/Lib/unittest/case.py
+++ b/Lib/unittest/case.py
@@ -384,11 +384,11 @@ class TestCase(object):
# of difflib. See #11763.
_diffThreshold = 2**16
- # Attribute used by TestSuite for classSetUp
-
- _classSetupFailed = False
-
- _class_cleanups = []
+ def __init_subclass__(cls, *args, **kwargs):
+ # Attribute used by TestSuite for classSetUp
+ cls._classSetupFailed = False
+ cls._class_cleanups = []
+ super().__init_subclass__(*args, **kwargs)
def __init__(self, methodName='runTest'):
"""Create an instance of the class that will use the named test