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.
This commit is contained in:
Serhiy Storchaka 2022-11-22 17:49:37 +02:00 committed by GitHub
parent d15b9f19ac
commit c2102136be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 5 deletions

View file

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