mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
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:
parent
d15b9f19ac
commit
c2102136be
3 changed files with 35 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue