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

Function test_unraisable

testing/test_unraisableexception.py:12–40  ·  view source on GitHub ↗
(pytester: Pytester)

Source from the content-addressed store, hash-verified

10
11@pytest.mark.filterwarnings("default::pytest.PytestUnraisableExceptionWarning")
12def test_unraisable(pytester: Pytester) -> None:
13 pytester.makepyfile(
14 test_it="""
15 class BrokenDel:
16 def __del__(self):
17 raise ValueError("del is broken")
18
19 def test_it():
20 obj = BrokenDel()
21 del obj
22
23 def test_2(): pass
24 """
25 )
26 result = pytester.runpytest()
27 assert result.ret == 0
28 assert result.parseoutcomes() == {"passed": 2, "warnings": 1}
29 result.stdout.fnmatch_lines(
30 [
31 "*= warnings summary =*",
32 "test_it.py::test_it",
33 " * PytestUnraisableExceptionWarning: Exception ignored in: <function BrokenDel.__del__ at *>",
34 " ",
35 " Traceback (most recent call last):",
36 " ValueError: del is broken",
37 " ",
38 " warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))",
39 ]
40 )
41
42
43@pytest.mark.filterwarnings("default::pytest.PytestUnraisableExceptionWarning")

Callers

nothing calls this directly

Calls 4

parseoutcomesMethod · 0.80
fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected