Skip to content

Commit 67fa068

Browse files
committed
docs(workflow): parallel and order-independent tests
why: The workflow guide's Tests section listed only serial runs; the new opt-in xdist mode (just test-parallel) and the suite's order-independence expectation were undocumented. what: - Add a "Running tests in parallel" subsection (just test-parallel / -n auto) - Add an "Order independence" subsection with a shuffled-run check
1 parent f8104de commit 67fa068

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

docs/project/workflow.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,31 @@ $ uv run py.test
2828

2929
Helpers: `just test` Rerun tests on file change: `just watch-test` (requires [entr(1)])
3030

31+
### Running tests in parallel
32+
33+
The suite spawns real `git`, `hg`, and `svn` processes, so on a multi-core
34+
machine it runs faster across workers with [pytest-xdist] (a dev dependency):
35+
36+
```console
37+
$ just test-parallel
38+
```
39+
40+
This runs `uv run py.test -n auto`, where `auto` sizes the worker pool to the
41+
machine's cores. Parallelism is opt-in — `just test` and `uv run py.test` stay
42+
serial by default.
43+
44+
### Order independence
45+
46+
Tests must pass regardless of the order they run in. Parallel and shuffled runs
47+
spread tests across workers, so any hidden coupling — shared global state, or a
48+
fixture that leaks into a later test — surfaces as a failure. Keep fixtures
49+
self-contained and reset any global state in teardown. Check locally with a
50+
shuffled run:
51+
52+
```console
53+
$ uv run --with pytest-randomly py.test -p randomly
54+
```
55+
3156
## Documentation
3257

3358
Default preview server: http://localhost:8068
@@ -220,6 +245,7 @@ Update `__version__` in `__about__.py` and `pyproject.toml`::
220245
uv publish
221246

222247
[uv]: https://github.com/astral-sh/uv
248+
[pytest-xdist]: https://pytest-xdist.readthedocs.io/
223249
[entr(1)]: http://eradman.com/entrproject/
224250
[`entr(1)`]: http://eradman.com/entrproject/
225251
[ruff format]: https://docs.astral.sh/ruff/formatter/

0 commit comments

Comments
 (0)