Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
DetachHead opened this issue Feb 1, 2024 · 0 comments

Comments

@DetachHead
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant