Command line¶
pytest-uv adds one option to pytest. It appears under Multi-version testing with uv
in pytest --help.
--python-versions¶
--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. |
auto |
Each installed final CPython release that satisfies [project] requires-python. |
See Choosing versions 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. |
-p no:xdist |
The workers are xdist workers. |
Exit codes¶
pytest's usual exit codes,
over all versions together. pytest-uv's own errors are usage errors (exit code 4),
with messages starting pytest-uv::
- no Python version matches (
autowith no suitable interpreter); declaredwithout[tool.pytest-uv] versions, orautowithoutrequires-python;- a version that is not a valid version request;
- an invalid
[tool.pytest-uv]value (for examplesync-argsthat is not a list of strings); uvnot found onPATH(or in theUVenvironment 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) |
-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 |