tox
tox is an environment orchestrator and test automation tool for Python that creates isolated environments and runs commands across them.
Installation and Setup
Install it from the Python Package Index (PyPI):
Key Features
- Creates isolated environments and runs test, lint, format, and other automation commands inside them.
- Selects multiple Python versions in a single run via environment names and the configured environment list.
- Builds and installs your project into environments to validate packaging and installation.
- Runs environments in parallel when requested to speed up local workflows and CI.
- Fits CI pipelines with reproducible environments, explicit configuration, and meaningful exit codes.
Usage
The tox tool discovers configuration in tox.ini, tox.toml, or pyproject.toml. A minimal pyproject.toml that runs tests on two Python versions and a linter looks like this:
TOML
pyproject.toml
[tool.tox]
envlist = ["py313", "py314", "lint"]
[tool.tox.env.py313]
deps = ["pytest"]
commands = [["pytest", "-q"]]
[tool.tox.env.py314]
deps = ["pytest"]
commands = [["pytest", "-q"]]
[tool.tox.env.lint]
deps = ["ruff"]
commands = [["ruff", "check", "."]]
Run all configured environments:
Shell
$ python -m tox
Run a specific environment:
Shell
$ python -m tox -e py313
Run environments in parallel using available CPUs:
Shell
$ python -m tox -p auto
Recreate environments when dependencies or settings change:
Shell
$ python -m tox -r
By Leodanis Pozo Ramos • Updated Dec. 17, 2025