Skip to content
Discussion options

You must be logged in to vote

🤖 Written by Claude Opus 5.5 via Claude Code for the pytest maintainers; I prompted it, it did the work, I read it.

pytest.exit() raised during fixture setup ends the whole session; it is not reported as a skip. On pytest 9.1, a session-scoped autouse fixture calling pytest.exit("...", returncode=1) stops before any test body runs and exits with that code, as the first answer shows. Calling it from pytest_sessionstart in the root conftest.py stops before collection.

If you saw a skip, check the code around the call: pytest.Exit subclasses Exception, so an except Exception: in your setup swallows it. To keep the error reported normally and stop after it, use -x / --maxfail=1. Under pytest-…

Replies: 2 comments

This comment was marked as low quality.

Comment options

You must be logged in to vote
0 replies
Answer selected by RonnyPfannschmidt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants