Skip to content
Edit this page

pytest-uv vs tox and tox-uv

tox creates a virtual environment per entry in env_list, installs the project and its dependencies into it, and runs the commands you configure. tox-uv replaces virtualenv and pip with uv inside tox, and adds a uv-venv-lock-runner that installs from uv.lock with uv sync.

The same task in both

Run the test suite on 3.11, 3.12 and 3.13, from uv.lock, with the test group.

tox, with tox-uv, in tox.ini:

[tox]
requires =
    tox>=4
    tox-uv>=1
env_list = py311, py312, py313

[testenv]
runner = uv-venv-lock-runner
dependency_groups = test
commands = pytest {posargs}
uv tool install tox --with tox-uv
tox run-parallel

pytest-uv, in pyproject.toml:

[dependency-groups]
test = ["pytest-uv"]

[tool.pytest-uv]
versions = ["3.11", "3.12", "3.13"]
sync-args = ["--no-default-groups", "--group", "test"]
uv run pytest --python-versions declared

Quick comparison

tox 4 with tox-uv pytest-uv
Runs Any commands per environment pytest
Configuration tox.ini, tox.toml or [tool.tox] Command-line option; optional [tool.pytest-uv]
Environments Named (py312, lint, docs), each with its own deps and commands One per Python version, same dependencies
Dependency matrices Factors (py312-django42) No
Parallel tox run-parallel (tox p), separate output per environment Always, one xdist worker per version, one report
From uv.lock runner = uv-venv-lock-runner Automatically when uv.lock exists
Reuse Recreates when its tracked inputs change, or with -r Rebuilds when pyproject.toml, uv.lock or its settings change
pytest options After --, passed through {posargs} Directly (--lf, -k, -x)
Installed as A tool (uv tool install tox --with tox-uv) A dev dependency

Which to choose

Choose tox when an environment means more than "this Python version": linting, type checking, docs, packaging checks, or factors over dependency versions. tox is the established tool for that, with many plugins, and tox-uv makes it fast.

Choose pytest-uv when the tox configuration you would write is only env_list and commands = pytest. You keep running pytest with its own options, get one report for all versions, and have no second configuration to maintain.

They don't exclude each other: a tox environment can run pytest --python-versions declared, or tox can keep the lint and docs environments while pytest-uv covers the version matrix.