MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_class_setup

Function test_class_setup

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

Source from the content-addressed store, hash-verified

78
79
80def 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
106def 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