MCPcopy
hub / github.com/pytest-dev/pytest / test_teardown_multiple_fail

Method test_teardown_multiple_fail

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

Source from the content-addressed store, hash-verified

82 assert r == ["fin3", "fin1"]
83
84 def test_teardown_multiple_fail(self, pytester: Pytester) -> None:
85 def fin1():
86 raise Exception("oops1")
87
88 def fin2():
89 raise Exception("oops2")
90
91 item = pytester.getitem("def test_func(): pass")
92 ss = item.session._setupstate
93 ss.setup(item)
94 ss.addfinalizer(fin1, item)
95 ss.addfinalizer(fin2, item)
96 with pytest.raises(ExceptionGroup) as err:
97 ss.teardown_exact(None)
98
99 # Note that finalizers are run LIFO, but because FIFO is more intuitive for
100 # users we reverse the order of messages, and see the error from fin1 first.
101 err1, err2 = err.value.exceptions
102 assert err1.args == ("oops1",)
103 assert err2.args == ("oops2",)
104
105 def test_teardown_multiple_scopes_one_fails(self, pytester: Pytester) -> None:
106 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