# pytest-uv

Run your test suite on every Python version you support, in one `pytest` command.

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

pytest-uv builds a virtual environment for each version with [uv](<https://docs.astral.sh/uv/>), starts one [pytest-xdist](<https://pytest-xdist.readthedocs.io/>) worker in each, and runs every test once per version. The failures of all versions come back in one report, so a test that breaks only on 3.11 shows up before you push, not in the third job of a CI matrix.

```text
$ uv run pytest --python-versions 3.11,3.12,3.13
created: 3/3 workers
3 workers [4 items]
............                                                             [100%]
============================== 12 passed in 2.01s ==============================
```

Four tests, three versions, twelve results.

## How it works

1. **Resolve versions.** From the list you pass, from `[tool.pytest-uv] versions` (`declared`), or from the installed interpreters that satisfy `requires-python` (`auto`). See [Choosing versions](<https://jirikuncar.github.io/pytest-uv/guide/versions/index.md>).
2. **Prepare environments.** For each version, `.pytest-uv/py<version>` is synced from `uv.lock` (`uv sync --frozen`), or installed with `uv pip install` when there is no lock file. Environments are built in parallel and reused until `pyproject.toml`, `uv.lock` or the settings change. See [Environments](<https://jirikuncar.github.io/pytest-uv/guide/environments/index.md>).
3. **Run.** One xdist worker per version, each importing only from its own environment, with `--dist each`. See [Worker isolation](<https://jirikuncar.github.io/pytest-uv/guide/isolation/index.md>).

## Where to go next

| If you want to | Read |
| --- | --- |
| Try it on a project | [Quickstart](<https://jirikuncar.github.io/pytest-uv/quickstart/index.md>) |
| Know whether it fits | [Why pytest-uv?](<https://jirikuncar.github.io/pytest-uv/motivation/index.md>) and [Comparisons](<https://jirikuncar.github.io/pytest-uv/alternatives/index.md>) |
| Run it in CI | [GitHub Actions](<https://jirikuncar.github.io/pytest-uv/recipes/ci/index.md>) |
| Debug a failure on one version | [Debugging failures](<https://jirikuncar.github.io/pytest-uv/guide/debugging/index.md>) |
| Look up an option or setting | [Command line](<https://jirikuncar.github.io/pytest-uv/reference/cli/index.md>), [Configuration](<https://jirikuncar.github.io/pytest-uv/reference/configuration/index.md>) |
| Let a coding agent use it | [Coding agents](<https://jirikuncar.github.io/pytest-uv/recipes/agents/index.md>) |
