tox is a generic virtual environment management and test command line tool, it aims to automate and standardize testing in Python.

Tox is less useful due to Github Actions, but Tox can be used as an automated testing tool when developing locally, running tests on the local machine, performing final checks before pushing, etc.

Installation

via pipx

1
2
3
python -m pip install pipx-in-pipx --user
pipx install tox
tox --help

via pip

1
2
python -m pip install --user tox
python -m tox --help

Usage

Test

Configuration

1
vim tox.ini
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
[tox]
requires =
    tox>=3
env_list = py37,py38,py39,py310,py311,pypy

[testenv]
description = run unit tests
downloadcache = .tox/_download/
deps =
    beautifulsoup4>=4.6.0
    html5lib>=1.0.1
    six>=1.11.0
    youtube_dl>=2021.12.17
    requests>=2.18.4
    tqdm>=4.64.0
    pytest>=2.5
    pytest-cov>=1.8.0
    pytest-xdist>=1.8
commands =
    py.test -v --cov edx_dl --cov-report html .

Command

create and set up environments to run command(s) in them

1
2
tox
tox --recreate

list environments

1
tox list

run environments

1
2
3
tox run
tox run -e ENV
tox run --recreate

run environments in parallel

1
2
3
tox run-parallel
tox run-parallel -e ENV
tox run-parallel --recreate

tox options

  • -r, --recreate - recreate the tox environments
  • -e ENV - select target environment