(pytester: Pytester)
| 1318 | sys.version_info < (3, 8), reason="Feature introduced in Python 3.8" |
| 1319 | ) |
| 1320 | def test_do_class_cleanups_on_success(pytester: Pytester) -> None: |
| 1321 | testpath = pytester.makepyfile( |
| 1322 | """ |
| 1323 | import unittest |
| 1324 | class MyTestCase(unittest.TestCase): |
| 1325 | values = [] |
| 1326 | @classmethod |
| 1327 | def setUpClass(cls): |
| 1328 | def cleanup(): |
| 1329 | cls.values.append(1) |
| 1330 | cls.addClassCleanup(cleanup) |
| 1331 | def test_one(self): |
| 1332 | pass |
| 1333 | def test_two(self): |
| 1334 | pass |
| 1335 | def test_cleanup_called_exactly_once(): |
| 1336 | assert MyTestCase.values == [1] |
| 1337 | """ |
| 1338 | ) |
| 1339 | reprec = pytester.inline_run(testpath) |
| 1340 | passed, skipped, failed = reprec.countoutcomes() |
| 1341 | assert failed == 0 |
| 1342 | assert passed == 3 |
| 1343 | |
| 1344 | |
| 1345 | @pytest.mark.skipif( |
nothing calls this directly
no test coverage detected