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