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

Function test_setup_setUpClass

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

Source from the content-addressed store, hash-verified

278
279
280def test_setup_setUpClass(pytester: Pytester) -> None:
281 testpath = pytester.makepyfile(
282 """
283 import unittest
284 import pytest
285 class MyTestCase(unittest.TestCase):
286 x = 0
287 @classmethod
288 def setUpClass(cls):
289 cls.x += 1
290 def test_func1(self):
291 assert self.x == 1
292 def test_func2(self):
293 assert self.x == 1
294 @classmethod
295 def tearDownClass(cls):
296 cls.x -= 1
297 def test_teareddown():
298 assert MyTestCase.x == 0
299 """
300 )
301 reprec = pytester.inline_run(testpath)
302 reprec.assertoutcome(passed=3)
303
304
305def test_fixtures_setup_setUpClass_issue8394(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 3

assertoutcomeMethod · 0.80
makepyfileMethod · 0.45
inline_runMethod · 0.45

Tested by

no test coverage detected