(pytester: Pytester)
| 1424 | |
| 1425 | |
| 1426 | def test_do_cleanups_on_setup_failure(pytester: Pytester) -> None: |
| 1427 | testpath = pytester.makepyfile( |
| 1428 | """ |
| 1429 | import unittest |
| 1430 | class MyTestCase(unittest.TestCase): |
| 1431 | values = [] |
| 1432 | def setUp(self): |
| 1433 | def cleanup(): |
| 1434 | self.values.append(1) |
| 1435 | self.addCleanup(cleanup) |
| 1436 | assert False |
| 1437 | def test_one(self): |
| 1438 | pass |
| 1439 | def test_two(self): |
| 1440 | pass |
| 1441 | def test_cleanup_called_the_right_number_of_times(): |
| 1442 | assert MyTestCase.values == [1, 1] |
| 1443 | """ |
| 1444 | ) |
| 1445 | reprec = pytester.inline_run(testpath) |
| 1446 | passed, skipped, failed = reprec.countoutcomes() |
| 1447 | assert failed == 2 |
| 1448 | assert passed == 1 |
| 1449 | |
| 1450 | |
| 1451 | def test_do_cleanups_on_teardown_failure(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected