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

Function test_setup_class

testing/test_unittest.py:329–349  ·  view source on GitHub ↗
(pytester: Pytester)

Source from the content-addressed store, hash-verified

327
328
329def test_setup_class(pytester: Pytester) -> None:
330 testpath = pytester.makepyfile(
331 """
332 import unittest
333 import pytest
334 class MyTestCase(unittest.TestCase):
335 x = 0
336 def setup_class(cls):
337 cls.x += 1
338 def test_func1(self):
339 assert self.x == 1
340 def test_func2(self):
341 assert self.x == 1
342 def teardown_class(cls):
343 cls.x -= 1
344 def test_teareddown():
345 assert MyTestCase.x == 0
346 """
347 )
348 reprec = pytester.inline_run(testpath)
349 reprec.assertoutcome(passed=3)
350
351
352@pytest.mark.parametrize("type", ["Error", "Failure"])

Callers

nothing calls this directly

Calls 3

assertoutcomeMethod · 0.80
makepyfileMethod · 0.45
inline_runMethod · 0.45

Tested by

no test coverage detected