(ret_exc, pytester: Pytester)
| 21 | ), |
| 22 | ) |
| 23 | def test_wrap_session_notify_exception(ret_exc, pytester: Pytester) -> None: |
| 24 | returncode, exc = ret_exc |
| 25 | c1 = pytester.makeconftest( |
| 26 | """ |
| 27 | import pytest |
| 28 | |
| 29 | def pytest_sessionstart(): |
| 30 | raise {exc}("boom") |
| 31 | |
| 32 | def pytest_internalerror(excrepr, excinfo): |
| 33 | returncode = {returncode!r} |
| 34 | if returncode is not False: |
| 35 | pytest.exit("exiting after %s..." % excinfo.typename, returncode={returncode!r}) |
| 36 | """.format( |
| 37 | returncode=returncode, exc=exc.__name__ |
| 38 | ) |
| 39 | ) |
| 40 | result = pytester.runpytest() |
| 41 | if returncode: |
| 42 | assert result.ret == returncode |
| 43 | else: |
| 44 | assert result.ret == ExitCode.INTERNAL_ERROR |
| 45 | assert result.stdout.lines[0] == "INTERNALERROR> Traceback (most recent call last):" |
| 46 | |
| 47 | if exc == SystemExit: |
| 48 | assert result.stdout.lines[-3:] == [ |
| 49 | f'INTERNALERROR> File "{c1}", line 4, in pytest_sessionstart', |
| 50 | 'INTERNALERROR> raise SystemExit("boom")', |
| 51 | "INTERNALERROR> SystemExit: boom", |
| 52 | ] |
| 53 | else: |
| 54 | assert result.stdout.lines[-3:] == [ |
| 55 | f'INTERNALERROR> File "{c1}", line 4, in pytest_sessionstart', |
| 56 | 'INTERNALERROR> raise ValueError("boom")', |
| 57 | "INTERNALERROR> ValueError: boom", |
| 58 | ] |
| 59 | if returncode is False: |
| 60 | assert result.stderr.lines == ["mainloop: caught unexpected SystemExit!"] |
| 61 | else: |
| 62 | assert result.stderr.lines == [f"Exit: exiting after {exc.__name__}..."] |
| 63 | |
| 64 | |
| 65 | @pytest.mark.parametrize("returncode", (None, 42)) |
nothing calls this directly
no test coverage detected