Skip to content

Propagate worker usage errors to controller#1345

Open
lin-hongkuan wants to merge 1 commit into
pytest-dev:masterfrom
lin-hongkuan:codex/propagate-worker-usage-errors
Open

Propagate worker usage errors to controller#1345
lin-hongkuan wants to merge 1 commit into
pytest-dev:masterfrom
lin-hongkuan:codex/propagate-worker-usage-errors

Conversation

@lin-hongkuan

Copy link
Copy Markdown

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 UsageError arguments on the worker output during collection, then has the controller re-raise pytest.UsageError when a worker finishes with ExitCode.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 -q
  • python -m pytest -p no:twisted testing\acceptance_test.py::TestDistribution -q
  • python -m pytest -p no:twisted testing\test_remote.py -q
  • python -m ruff check src\xdist\remote.py src\xdist\dsession.py testing\acceptance_test.py
  • python -m ruff format --check src\xdist\remote.py src\xdist\dsession.py testing\acceptance_test.py
  • python -m mypy --ignore-missing-imports src\xdist\remote.py src\xdist\dsession.py testing\acceptance_test.py

I also manually verified python -m pytest -n2 MISSING now returns 4 and prints ERROR: file or directory not found: MISSING. A full local python -m pytest -p no:twisted -q run was attempted but exceeded 5 minutes before completing in this environment.

Comment thread src/xdist/remote.py

@pytest.hookimpl
def pytest_collection(self) -> None:
@pytest.hookimpl(hookwrapper=True)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use modern wrappers

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

Successfully merging this pull request may close these issues.

xdist munges error message if a requested path does not exist

2 participants