Skip to content
Edit this page

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

  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.
  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.
  3. 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