(pytester: Pytester)
| 191 | |
| 192 | |
| 193 | def test_unraisable_collection_failure(pytester: Pytester) -> None: |
| 194 | pytester.makepyfile( |
| 195 | test_it=f""" |
| 196 | class BrokenDel: |
| 197 | def __del__(self): |
| 198 | raise ValueError("del is broken") |
| 199 | |
| 200 | def test_it(): |
| 201 | obj = BrokenDel() |
| 202 | del obj |
| 203 | {"import gc; gc.collect()" * PYPY} |
| 204 | |
| 205 | def test_2(): pass |
| 206 | """ |
| 207 | ) |
| 208 | |
| 209 | class MyError(BaseException): |
| 210 | pass |
| 211 | |
| 212 | with mock.patch("traceback.format_exception", side_effect=MyError): |
| 213 | result = pytester.runpytest() |
| 214 | assert result.ret == 1 |
| 215 | result.assert_outcomes(passed=1, failed=1) |
| 216 | result.stdout.fnmatch_lines( |
| 217 | ["E RuntimeError: Failed to process unraisable exception"] |
| 218 | ) |
| 219 | |
| 220 | |
| 221 | def _set_gc_state(enabled: bool) -> bool: |
nothing calls this directly
no test coverage detected