pytest-xdist icon indicating copy to clipboard operation
pytest-xdist copied to clipboard

exit code 0 returned to pytester when an internal error occurs inside a `pytest_runtest_protocol` hook

Open DetachHead opened this issue 1 year ago • 0 comments

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

DetachHead avatar Feb 01 '24 02:02 DetachHead