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

Method testCleanUp

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

Source from the content-addressed store, hash-verified

82
83class TestCleanUp(unittest.TestCase):
84 def testCleanUp(self):
85 class TestableTest(unittest.TestCase):
86 def testNothing(self):
87 pass
88
89 test = TestableTest('testNothing')
90 self.assertEqual(test._cleanups, [])
91
92 cleanups = []
93
94 def cleanup1(*args, **kwargs):
95 cleanups.append((1, args, kwargs))
96
97 def cleanup2(*args, **kwargs):
98 cleanups.append((2, args, kwargs))
99
100 test.addCleanup(cleanup1, 1, 2, 3, four='hello', five='goodbye')
101 test.addCleanup(cleanup2)
102
103 self.assertEqual(test._cleanups,
104 [(cleanup1, (1, 2, 3), dict(four='hello', five='goodbye')),
105 (cleanup2, (), {})])
106
107 self.assertTrue(test.doCleanups())
108 self.assertEqual(cleanups, [(2, (), {}), (1, (1, 2, 3), dict(four='hello', five='goodbye'))])
109
110 @support.force_not_colorized
111 def testCleanUpWithErrors(self):

Callers

nothing calls this directly

Calls 5

addCleanupMethod · 0.80
assertTrueMethod · 0.80
doCleanupsMethod · 0.80
TestableTestClass · 0.70
assertEqualMethod · 0.45

Tested by

no test coverage detected