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

Method test_teardown_multiple_fail

testing/test_runner.py:79–95  ·  view source on GitHub ↗
(self, pytester: Pytester)

Source from the content-addressed store, hash-verified

77 assert r == ["fin3", "fin1"]
78
79 def test_teardown_multiple_fail(self, pytester: Pytester) -> None:
80 # Ensure the first exception is the one which is re-raised.
81 # Ideally both would be reported however.
82 def fin1():
83 raise Exception("oops1")
84
85 def fin2():
86 raise Exception("oops2")
87
88 item = pytester.getitem("def test_func(): pass")
89 ss = item.session._setupstate
90 ss.setup(item)
91 ss.addfinalizer(fin1, item)
92 ss.addfinalizer(fin2, item)
93 with pytest.raises(Exception) as err:
94 ss.teardown_exact(None)
95 assert err.value.args == ("oops2",)
96
97 def test_teardown_multiple_scopes_one_fails(self, pytester: Pytester) -> None:
98 module_teardown = []

Callers

nothing calls this directly

Calls 4

teardown_exactMethod · 0.80
getitemMethod · 0.45
setupMethod · 0.45
addfinalizerMethod · 0.45

Tested by

no test coverage detected