feat: run pytest in parallel with pytest-xdist by default - #36
Merged
Merged
Conversation
- Add pytest-xdist to the dev group and regenerate uv.lock - Pass --numprocesses=auto through [tool.pytest] addopts so every pytest invocation, local or CI, distributes tests across all CPU cores
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.
Overview and Background
Generated projects now run their test suite in parallel by default:
pytestdistributes tests across all CPU cores through pytest-xdist. Previously tests ran serially, so suites that grow beyond the template's three example tests paid the full wall-clock cost in CI and in agent-driven edit/test loops.Related Issues
None
Implementation Approach
pytest-xdist>=3.8.0joins the dev dependency group anduv.lockis regenerated (adds pytest-xdist and its execnet dependency).--numprocesses=autois appended to[tool.pytest] addopts, so it applies to every invocation without changing the CI commands. The long option name is used for readability in TOML.pytest --covstill produces one combined report and enforces the 80% threshold.--pdb,-swith interactive input) works by overriding on the command line:pytest -n 0.Changes
template/pyproject.toml:pytest-xdistin the dev group (list reformatted one-per-line as it grew);--numprocesses=autoinaddopts.template/uv.lock: regenerated.Impact
pytestoutput now starts with the worker count line and test order is no longer deterministic across files. Tests that share mutable global state must be made independent or grouped with@pytest.mark.xdist_group.uv.lock(feat: keep uv.lock across template updates and print next steps #27); they needuv lockto add pytest-xdist.Validation Results