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