# pytest-uv vs pytest-xdist alone

pytest-uv is built on [pytest-xdist](<https://pytest-xdist.readthedocs.io/>). xdist can start workers with any interpreter (`--tx popen//python=...`) and send every test to every worker (`--dist each`), which is the core of a multi-version run.

## The same task in both

xdist alone, with environments you prepare yourself:

```bash
for v in 3.11 3.12 3.13; do
  uv venv --python "$v" ".venv-$v"
  uv pip install --python ".venv-$v/bin/python" -e . pytest pytest-xdist
done

uv run pytest --dist each \
  --tx popen//python=.venv-3.11/bin/python \
  --tx popen//python=.venv-3.12/bin/python \
  --tx popen//python=.venv-3.13/bin/python
```

pytest-uv:

```bash
uv run pytest --python-versions 3.11,3.12,3.13
```

## Quick comparison

|  | pytest-xdist alone | pytest-uv |
| --- | --- | --- |
| Main use | Spread tests over CPUs (`-n auto`) or hosts | One run per Python version |
| Environments | You create and update them | Built from `uv.lock` or `install-args`, reused until inputs change |
| Version list | One `--tx` per interpreter | `3.11,3.12`, `declared` or `auto` |
| Worker imports | The controller's `sys.path` is sent to each `popen` worker | Each worker uses its own environment's `sys.path` ([details](<https://jirikuncar.github.io/pytest-uv/guide/isolation/index.md>)) |
| Worker's version in tests | `sys.version_info` | `sys.version_info` and the `python_version` fixture |
| `-n` with several versions | Not applicable | A usage error: one worker per version |

## Which to choose

**Choose xdist alone** to make one version's suite faster: `pytest -n auto`. pytest-uv does not do that, and refuses `-n` together with `--python-versions`. Also choose it for remote hosts or custom execnet gateways.

**Choose pytest-uv** to run on several versions: it builds and refreshes the environments, keeps each worker's imports inside its own environment, and chooses the versions from your project's metadata.

Both are installed together: pytest-uv depends on pytest-xdist, so `pytest -n auto` keeps working for single-version runs.
