(pytester: Pytester)
| 42 | |
| 43 | @pytest.mark.filterwarnings("default::pytest.PytestUnraisableExceptionWarning") |
| 44 | def test_unraisable_in_setup(pytester: Pytester) -> None: |
| 45 | pytester.makepyfile( |
| 46 | test_it=""" |
| 47 | import pytest |
| 48 | |
| 49 | class BrokenDel: |
| 50 | def __del__(self): |
| 51 | raise ValueError("del is broken") |
| 52 | |
| 53 | @pytest.fixture |
| 54 | def broken_del(): |
| 55 | obj = BrokenDel() |
| 56 | del obj |
| 57 | |
| 58 | def test_it(broken_del): pass |
| 59 | def test_2(): pass |
| 60 | """ |
| 61 | ) |
| 62 | result = pytester.runpytest() |
| 63 | assert result.ret == 0 |
| 64 | assert result.parseoutcomes() == {"passed": 2, "warnings": 1} |
| 65 | result.stdout.fnmatch_lines( |
| 66 | [ |
| 67 | "*= warnings summary =*", |
| 68 | "test_it.py::test_it", |
| 69 | " * PytestUnraisableExceptionWarning: Exception ignored in: <function BrokenDel.__del__ at *>", |
| 70 | " ", |
| 71 | " Traceback (most recent call last):", |
| 72 | " ValueError: del is broken", |
| 73 | " ", |
| 74 | " warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))", |
| 75 | ] |
| 76 | ) |
| 77 | |
| 78 | |
| 79 | @pytest.mark.filterwarnings("default::pytest.PytestUnraisableExceptionWarning") |
nothing calls this directly
no test coverage detected