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

Function test_do_cleanups_on_setup_failure

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

Source from the content-addressed store, hash-verified

1424
1425
1426def test_do_cleanups_on_setup_failure(pytester: Pytester) -> None:
1427 testpath = pytester.makepyfile(
1428 """
1429 import unittest
1430 class MyTestCase(unittest.TestCase):
1431 values = []
1432 def setUp(self):
1433 def cleanup():
1434 self.values.append(1)
1435 self.addCleanup(cleanup)
1436 assert False
1437 def test_one(self):
1438 pass
1439 def test_two(self):
1440 pass
1441 def test_cleanup_called_the_right_number_of_times():
1442 assert MyTestCase.values == [1, 1]
1443 """
1444 )
1445 reprec = pytester.inline_run(testpath)
1446 passed, skipped, failed = reprec.countoutcomes()
1447 assert failed == 2
1448 assert passed == 1
1449
1450
1451def test_do_cleanups_on_teardown_failure(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 3

countoutcomesMethod · 0.80
makepyfileMethod · 0.45
inline_runMethod · 0.45

Tested by

no test coverage detected