MCPcopy Index your code
hub / github.com/python/cpython / addCleanup

Method addCleanup

Lib/unittest/case.py:465–471  ·  view source on GitHub ↗

Add a function, with arguments, to be called when the test is completed. Functions added are called on a LIFO basis and are called after tearDown on test failure or success. Cleanup items are called even if setUp fails (unlike tearDown).

(self, function, /, *args, **kwargs)

Source from the content-addressed store, hash-verified

463 self._type_equality_funcs[typeobj] = function
464
465 def addCleanup(self, function, /, *args, **kwargs):
466 """Add a function, with arguments, to be called when the test is
467 completed. Functions added are called on a LIFO basis and are
468 called after tearDown on test failure or success.
469
470 Cleanup items are called even if setUp fails (unlike tearDown)."""
471 self._cleanups.append((function, args, kwargs))
472
473 def enterContext(self, cm):
474 """Enters the supplied context manager.

Calls 1

appendMethod · 0.45