pytest-xdist
pytest-xdist copied to clipboard
exit code 0 returned to pytester when an internal error occurs inside a `pytest_runtest_protocol` hook
i'm not sure if this is an issue with pytest-xdist or pytester, but when testing a pytest plugin that raises an exception with pytest-xdist, pytester incorrectly says the exit code was 0, when it should be 3.
from pytest import ExitCode, Pytester
def test_asdf(pytester: Pytester):
pytester.makeconftest(
"""
def pytest_runtest_protocol():
raise Exception("asdf")
"""
)
pytester.makepyfile(
"""
def test_foo(): ...
"""
)
result = pytester.runpytest("-n", "2")
assert [
line for line in result.outlines if line.startswith("INTERNALERROR>")
] # passes
assert result.ret != ExitCode.OK # fails