(pytester: Pytester)
| 10 | |
| 11 | @pytest.mark.filterwarnings("default::pytest.PytestUnraisableExceptionWarning") |
| 12 | def 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") |
nothing calls this directly
no test coverage detected