# Command line

pytest-uv adds one option to pytest. It appears under `Multi-version testing with uv` in `pytest --help`.

## `--python-versions`

```text
--python-versions=VERSIONS
```

| Value | Meaning |
| --- | --- |
| `3.11,3.12,3.13` | These minor versions, comma-separated. Missing interpreters are downloaded by uv. |
| `declared` | The versions in [`[tool.pytest-uv] versions`](<https://jirikuncar.github.io/pytest-uv/reference/configuration/index.md#versions>). |
| `auto` | Each installed final CPython release that satisfies `[project] requires-python`. |

See [Choosing versions](<https://jirikuncar.github.io/pytest-uv/guide/versions/index.md>) for when to use which.

Without the option, pytest-uv does nothing.

## What it sets for pytest-xdist

With `--python-versions`, pytest-uv configures xdist itself:

| xdist option | Value |
| --- | --- |
| `--tx` | One `popen//python=<venv-dir>/py<version>/bin/python` per version |
| `--dist` | `each`: every test runs on every worker, so once per version |

## Options it cannot be combined with

Each of these, together with `--python-versions`, stops pytest with a usage error (exit code 4) that says why:

| Option | Why |
| --- | --- |
| `-n`, `--numprocesses` | Each version gets exactly one worker. To spread one version's tests over CPUs, run `pytest -n auto` without `--python-versions`. `-n 0` is accepted, to cancel an `-n` from `addopts`. |
| `--dist` other than `each` | `load`, `loadscope` and the other modes split tests between workers, so each test would run on one version only. |
| `--tx` | pytest-uv creates one worker per version itself. |
| `--pdb` | Debuggers need a terminal, which xdist workers don't have; see [Debugging failures](<https://jirikuncar.github.io/pytest-uv/guide/debugging/index.md#step-through-with-pdb-or-breakpoint>). |
| `-p no:xdist` | The workers are xdist workers. |

## Exit codes

pytest's usual [exit codes](<https://docs.pytest.org/en/stable/reference/exit-codes.html>), over all versions together. pytest-uv's own errors are usage errors (exit code 4), with messages starting `pytest-uv:`:

- no Python version matches (`auto` with no suitable interpreter);
- `declared` without `[tool.pytest-uv] versions`, or `auto` without `requires-python`;
- a version that is not a valid version request;
- an invalid `[tool.pytest-uv]` value (for example `sync-args` that is not a list of strings);
- `uv` not found on `PATH` (or in the `UV` environment variable);
- uv failed to build an environment (the message includes uv's output);
- one of the options above.

With `--collect-only`, versions are resolved but no environments are built.

## Related pytest options

| Option | With pytest-uv |
| --- | --- |
| `-v` | Also streams uv's output while environments are built |
| `--lf`, `--ff` | Work, but re-run failures on every version ([details](<https://jirikuncar.github.io/pytest-uv/guide/debugging/index.md#re-run-last-failures-with-lf>)) |
| `-x` | Stops the whole session at the first failure on any version |
| `-s` | Has no effect on workers (an xdist limitation) |
| `-p no:uv` | Disables the plugin |
