(self)
| 82 | |
| 83 | class 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): |
nothing calls this directly
no test coverage detected