(pytester: Pytester)
| 10 | |
| 11 | @pytest.mark.filterwarnings("default::pytest.PytestUnhandledThreadExceptionWarning") |
| 12 | def test_unhandled_thread_exception(pytester: Pytester) -> None: |
| 13 | pytester.makepyfile( |
| 14 | test_it=""" |
| 15 | import threading |
| 16 | |
| 17 | def test_it(): |
| 18 | def oops(): |
| 19 | raise ValueError("Oops") |
| 20 | |
| 21 | t = threading.Thread(target=oops, name="MyThread") |
| 22 | t.start() |
| 23 | t.join() |
| 24 | |
| 25 | def test_2(): pass |
| 26 | """ |
| 27 | ) |
| 28 | result = pytester.runpytest() |
| 29 | assert result.ret == 0 |
| 30 | assert result.parseoutcomes() == {"passed": 2, "warnings": 1} |
| 31 | result.stdout.fnmatch_lines( |
| 32 | [ |
| 33 | "*= warnings summary =*", |
| 34 | "test_it.py::test_it", |
| 35 | " * PytestUnhandledThreadExceptionWarning: Exception in thread MyThread", |
| 36 | " ", |
| 37 | " Traceback (most recent call last):", |
| 38 | " ValueError: Oops", |
| 39 | " ", |
| 40 | " warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))", |
| 41 | ] |
| 42 | ) |
| 43 | |
| 44 | |
| 45 | @pytest.mark.filterwarnings("default::pytest.PytestUnhandledThreadExceptionWarning") |
nothing calls this directly
no test coverage detected