Skip to content

Honor --continue-on-collection-errors in distributed runs - #1437

Open
AyaanshC wants to merge 2 commits into
pytest-dev:masterfrom
AyaanshC:codex/stop-on-collection-errors
Open

AyaanshC wants to merge 2 commits into
pytest-dev:masterfrom
AyaanshC:codex/stop-on-collection-errors

Conversation

@AyaanshC

@AyaanshC AyaanshC commented Nov 26, 2026 •

Copy link
Copy Markdown

Proposed change

Refs #1087. With one module that raises during collection and another that collects successfully, serial pytest stops with exit code 2 by default. xdist currently runs the collected test and exits with code 1. I reproduced this with and without --lf --last-failed-no-failures none.

This draft proposes making the distributed default match serial pytest. The controller stops before scheduling tests if a worker reported a collection failure. --continue-on-collection-errors retains the current behavior for users who want to run the successfully collected tests.

I'd appreciate feedback on changing the default and exit status in xdist before moving this out of draft.

Verification

  • The two regression cases fail on the original checkout and pass with this change. The opt-in case continues running the collected test.
  • The five focused acceptance cases pass with pytest 7.0.0 and 9.2.0. The pytest 7 run suppresses its Python 3.12 AST deprecation warnings.
  • Verified the default and opt-in behavior across all six built-in scheduler modes. The session tests, Ruff, mypy, and changelog lint passed.
  • The full local suite exited successfully with 250 passed, 6 skipped, 9 xfailed, and 1 xpassed.

Review follow-up

Rebased onto master with #1408. The stop reason now matches serial pytest for one or several distinct collection errors, even if two workers report the same traceback. The removal changelog entry explains exit code 2 and the option to restore the previous behavior.

The updated collection and worker-usage regression selection passed with pytest 7.0.0 and 9.2.0 (13 tests on each). The full Linux suite on pytest 9.2.0 returned 264 passed, 6 skipped, and 10 expected failures.

AI assistance

OpenAI Codex assisted with investigation, the code and tests, and the PR description. AyaanshC reviewed the original patch. Codex prepared the follow-up described above.

Copy link
Copy Markdown
Member

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

I reproduced this on master. Serial pytest stops with "Interrupted: 1 error during collection" (exit 2), while -n2 runs the remaining test and exits 1. Matching serial pytest is the right default, so I'm fine with changing it.

Before this leaves draft:

  • Please rebase on master so CI runs with fix(workers): preserve usage-error diagnostics and exit status #1408.
  • Please use pytest's wording for the stop reason ("1 error during collection" / "N errors during collection"), so the output matches serial runs.
  • This changes the default exit status and stops running the remaining tests. Please make the changelog a removal entry (changelog/1087.removal.rst) that says so, and mention that --continue-on-collection-errors restores the old behavior.

Generated by Claude Code

@AyaanshC
AyaanshC force-pushed the codex/stop-on-collection-errors branch from 4c65361 to aa9c7b5 Compare November 28, 2026 07:02
@AyaanshC
AyaanshC marked this pull request as ready for review November 28, 2026 07:05

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants