Running
tox
Run the envs in env_list
tox run
Same, explicit subcommand (alias r)
tox -e <env>
Run a single environment
tox -e <e1>,<e2>
Run several named environments
tox -e <env> -- <args>
Forward args to {posargs}
tox -e ALL
Run every defined environment
tox -r -e <env>
Recreate the env from scratch
tox -f <factor>
Run envs containing a factor
Several names after one -f must all match; repeat -f for OR.
tox -m <label>
Run envs under a label
tox --skip-env <regex>
Exclude envs matching a regex
tox -s
Skip missing interpreters
tox --fail-fast
Stop after the first failing env
tox -n -e <env>
Build the env, skip the commands
tox -i
Disable output capture
tox -v
More verbose (repeat for more)
tox -c <file>
Use another config file or folder
tox -x <env>.<key>=<val>
Override one config value
tox --installpkg <file>
Test a prebuilt sdist or wheel
Config file
[tox]
Core section in tox.ini
env_list = <e1>, <e2>
Default environments
requires = tox>=4.2
Needed tox and plugins (auto-provisioned)
labels = <name>=<e1>,<e2>
Name a group of envs
[testenv]
Base section for all envs
[testenv:<env>]
Settings for one env
description = <text>
Shown by tox l
deps = <pkg>
Packages to install
commands = <cmd> {posargs}
Commands to run, one per line
commands_pre = <cmd>
Run before commands
commands_post = <cmd>
Run after commands, even on failure
extras = <name>
Install optional dependencies
pass_env = <VAR>
Let env vars through to the env
set_env = <VAR>=<val>
Set env vars
change_dir = <dir>
Working dir for commands
allowlist_externals = <cmd>
Allow commands from outside the env
Without this tox refuses system commands such as make.
base_python = python3.13
Pick the interpreter
skip_install = true
Do not install your package
package = wheel
sdist, wheel, editable or skip
dependency_groups = <group>
Install PEP 735 groups (tox 4.22+)
depends = <env>
Run only after another env (parallel)
ignore_outcome = true
Report failure without failing the run
ignore_errors = true
Continue after a failing command
Recipes
Minimal tox.ini
[tox]env_list = lint, py313[testenv]deps = pytestcommands = pytest {posargs}[testenv:lint]skip_install = truedeps = ruffcommands = ruff check .
Matrix with factors
[tox]env_list = py3{12,13}-{django,flask}[testenv]deps = pytest django: django flask: flaskcommands = pytest
Native tox.toml
env_list = ["lint", "3.13"][env_run_base]dependency_groups = ["test"]commands = [["pytest", { replace = "posargs", extend = true }]][env.lint]skip_install = truedeps = ["ruff"]commands = [["ruff", "check", "."]]
One test, fresh env
tox -r -e py313 -- -x -k <name>
Same matrix in CI
tox -e py313tox p