MCPcopy Index your code
hub / github.com/RustPython/RustPython / testCleanUp

Method testCleanUp

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

Source from the content-addressed store, hash-verified

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