MCPcopy
hub / github.com/pytest-dev/pytest / test_class_setup

Function test_class_setup

testing/test_runner_xunit.py:82–105  ·  view source on GitHub ↗
(pytester: Pytester)

Source from the content-addressed store, hash-verified

80
81
82def 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
108def test_class_setup_failure_no_teardown(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 2

assertoutcomeMethod · 0.80
inline_runsourceMethod · 0.45

Tested by

no test coverage detected