(pytester: Pytester)
| 78 | |
| 79 | |
| 80 | def test_class_setup(pytester: Pytester) -> None: |
| 81 | reprec = pytester.inline_runsource( |
| 82 | """ |
| 83 | class TestSimpleClassSetup(object): |
| 84 | clslevel = [] |
| 85 | def setup_class(cls): |
| 86 | cls.clslevel.append(23) |
| 87 | |
| 88 | def teardown_class(cls): |
| 89 | cls.clslevel.pop() |
| 90 | |
| 91 | def test_classlevel(self): |
| 92 | assert self.clslevel[0] == 23 |
| 93 | |
| 94 | class TestInheritedClassSetupStillWorks(TestSimpleClassSetup): |
| 95 | def test_classlevel_anothertime(self): |
| 96 | assert self.clslevel == [23] |
| 97 | |
| 98 | def test_cleanup(): |
| 99 | assert not TestSimpleClassSetup.clslevel |
| 100 | assert not TestInheritedClassSetupStillWorks.clslevel |
| 101 | """ |
| 102 | ) |
| 103 | reprec.assertoutcome(passed=1 + 2 + 1) |
| 104 | |
| 105 | |
| 106 | def test_class_setup_failure_no_teardown(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected