pytest-uv¶
Run your test suite on every Python version you support, in one pytest command.
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, starts one pytest-xdist 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.
$ 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¶
- Resolve versions. From the list you pass, from
[tool.pytest-uv] versions(declared), or from the installed interpreters that satisfyrequires-python(auto). See Choosing versions. - Prepare environments. For each version,
.pytest-uv/py<version>is synced fromuv.lock(uv sync --frozen), or installed withuv pip installwhen there is no lock file. Environments are built in parallel and reused untilpyproject.toml,uv.lockor the settings change. See Environments. - Run. One xdist worker per version, each importing only from its own
environment, with
--dist each. See Worker isolation.
Where to go next¶
| If you want to | Read |
|---|---|
| Try it on a project | Quickstart |
| Know whether it fits | Why pytest-uv? and Comparisons |
| Run it in CI | GitHub Actions |
| Debug a failure on one version | Debugging failures |
| Look up an option or setting | Command line, Configuration |
| Let a coding agent use it | Coding agents |