We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2c0b508 commit 1b46612Copy full SHA for 1b46612
python-stdlib/unittest/unittest.py
@@ -41,6 +41,17 @@ class TestCase:
41
def __init__(self):
42
pass
43
44
+ def addCleanup(self, func, *args, **kwargs):
45
+ if not hasattr(self, "_cleanups"):
46
+ self._cleanups = []
47
+ self._cleanups.append((func, args, kwargs))
48
+
49
+ def doCleanups(self):
50
+ if hasattr(self, "_cleanups"):
51
+ while self._cleanups:
52
+ func, args, kwargs = self._cleanups.pop()
53
+ func(*args, **kwargs)
54
55
def subTest(self, msg=None, **params):
56
return NullContext()
57
@@ -271,6 +282,7 @@ def run_suite(c, test_result):
271
282
continue
272
283
finally:
273
284
tear_down()
285
+ o.doCleanups()
274
286
return exceptions
275
287
276
288
0 commit comments