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

Function test_no_teardown_if_setupclass_failed

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

Source from the content-addressed store, hash-verified

890
891
892def test_no_teardown_if_setupclass_failed(pytester: Pytester) -> None:
893 testpath = pytester.makepyfile(
894 """
895 import unittest
896
897 class MyTestCase(unittest.TestCase):
898 x = 0
899
900 @classmethod
901 def setUpClass(cls):
902 cls.x = 1
903 assert False
904
905 def test_func1(self):
906 cls.x = 10
907
908 @classmethod
909 def tearDownClass(cls):
910 cls.x = 100
911
912 def test_notTornDown():
913 assert MyTestCase.x == 1
914 """
915 )
916 reprec = pytester.inline_run(testpath)
917 reprec.assertoutcome(passed=1, failed=1)
918
919
920def test_cleanup_functions(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