# Installation

pytest-uv is a pytest plugin. Add it to the development dependencies of the project whose tests you want to run:

```bash
uv add --dev pytest-uv
```

This puts it in the `dev` [dependency group](<https://docs.astral.sh/uv/concepts/projects/dependencies/#development-dependencies>), which uv installs by default. pytest registers the plugin on its own; there is nothing to add to `conftest.py`. With pip:

```bash
pip install pytest-uv
```

The per-version environments go to `.pytest-uv/`, which contains its own `.gitignore`, so git ignores it without changes to yours.

## Requirements

| Requirement | Why |
| --- | --- |
| [uv](<https://docs.astral.sh/uv/getting-started/installation/>) on `PATH` | Finds and installs interpreters, builds the environments |
| Python 3.11 or newer for the environment pytest runs in | The plugin itself; the versions it tests follow your `requires-python` |
| pytest and pytest-xdist | Installed with pytest-uv; added to each per-version environment if missing, with pytest-uv itself |

**Projects that still support Python 3.10 or older:** pytest-uv requires Python 3.11, so a plain `uv add --dev pytest-uv` fails to resolve for a project with `requires-python = ">=3.9"`. Add it with a marker: `uv add --dev "pytest-uv; python_version >= '3.11'"`, and run the controller on 3.11 or newer. Workers for older versions still run every test, but without the plugin, so the `python_version` fixture is not available there.

Check that the plugin is loaded:

```bash
uv run pytest --help | grep -A3 python-versions
```

## Python interpreters

You don't have to install the versions you test. When you pass a version that is not installed, uv downloads it (uv's default [`python-downloads = "automatic"`](<https://docs.astral.sh/uv/reference/settings/#python-downloads>)). To install them ahead of time, for example in CI:

```bash
uv python install 3.11 3.12 3.13 3.14
```

`--python-versions auto` only uses interpreters that are already installed; list them with `uv python list --only-installed`.

## Coding agents

To teach Claude Code, Codex or Cursor how to use pytest-uv, see [Coding agents](<https://jirikuncar.github.io/pytest-uv/recipes/agents/index.md>).
