Propagate worker usage errors to controller#1345
Open
lin-hongkuan wants to merge 1 commit into
Open
Conversation
RonnyPfannschmidt
requested changes
Jun 25, 2026
|
|
||
| @pytest.hookimpl | ||
| def pytest_collection(self) -> None: | ||
| @pytest.hookimpl(hookwrapper=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #109.
When collection on a worker raises
pytest.UsageError(for example because a requested path does not exist), the worker exits with status 4 but the controller currently only sees an empty collection and finishes as "no tests ran" with exit code 5.This stores the original
UsageErrorarguments on the worker output during collection, then has the controller re-raisepytest.UsageErrorwhen a worker finishes withExitCode.USAGE_ERROR. That lets pytest print the original error message and preserve the usage-error exit code.Validation:
python -m pytest -p no:twisted testing\acceptance_test.py::TestDistribution::test_missing_path_usage_error -qpython -m pytest -p no:twisted testing\acceptance_test.py::TestDistribution -qpython -m pytest -p no:twisted testing\test_remote.py -qpython -m ruff check src\xdist\remote.py src\xdist\dsession.py testing\acceptance_test.pypython -m ruff format --check src\xdist\remote.py src\xdist\dsession.py testing\acceptance_test.pypython -m mypy --ignore-missing-imports src\xdist\remote.py src\xdist\dsession.py testing\acceptance_test.pyI also manually verified
python -m pytest -n2 MISSINGnow returns 4 and printsERROR: file or directory not found: MISSING. A full localpython -m pytest -p no:twisted -qrun was attempted but exceeded 5 minutes before completing in this environment.