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:
pyproject.toml
[tool.tox]
env_list = ["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:
$ python -m tox
Run a specific environment:
$ python -m tox -e py313
Run environments in parallel using available CPUs:
$ python -m tox -p auto
Recreate environments when dependencies or settings change:
$ python -m tox -r
Related Resources
Course
Testing Your Code With pytest
In this video course, you'll learn how to take your testing to the next level with pytest. You'll cover intermediate and advanced pytest features such as fixtures, marks, parameters, and plugins. With pytest, you can make your test suites fast, effective, and less painful to maintain.
By Leodanis Pozo Ramos • Updated July 20, 2026