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

Method test_addClassCleanUp

Lib/test/test_unittest/test_runner.py:256–281  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

254@support.force_not_colorized_test_class
255class TestClassCleanup(unittest.TestCase):
256 def test_addClassCleanUp(self):
257 class TestableTest(unittest.TestCase):
258 def testNothing(self):
259 pass
260 test = TestableTest('testNothing')
261 self.assertEqual(test._class_cleanups, [])
262 class_cleanups = []
263
264 def class_cleanup1(*args, **kwargs):
265 class_cleanups.append((3, args, kwargs))
266
267 def class_cleanup2(*args, **kwargs):
268 class_cleanups.append((4, args, kwargs))
269
270 TestableTest.addClassCleanup(class_cleanup1, 1, 2, 3,
271 four='hello', five='goodbye')
272 TestableTest.addClassCleanup(class_cleanup2)
273
274 self.assertEqual(test._class_cleanups,
275 [(class_cleanup1, (1, 2, 3),
276 dict(four='hello', five='goodbye')),
277 (class_cleanup2, (), {})])
278
279 TestableTest.doClassCleanups()
280 self.assertEqual(class_cleanups, [(4, (), {}), (3, (1, 2, 3),
281 dict(four='hello', five='goodbye'))])
282
283 def test_run_class_cleanUp(self):
284 ordering = []

Callers

nothing calls this directly

Calls 4

addClassCleanupMethod · 0.80
doClassCleanupsMethod · 0.80
TestableTestClass · 0.70
assertEqualMethod · 0.45

Tested by

no test coverage detected