Using Tox with a CI environment is usually fairly simple, but as both Tox and the CI will probably end up wanting to manage the Python environment, some attention has to be paid to enable them to exist together. To see how Travis and Tox can work together, we can pick our chat project that we wrote in Chapter 4, Scaling the Test Suite, which we already had on Travis-CI, and migrate it to use Tox.
We need to write a tox.ini file, which will take care of running the test suite itself:
[tox]
setupdir = ./src
envlist = py37, py38, py39
[testenv]
usedevelop = true
deps =
coverage
commands =
coverage run --source=src -m unittest discover tests -v
coverage report
[testenv:benchmarks]
commands =
python -m unittest discover benchmarks
The commands you see in tox.ini are the same that we previously had in the travis.yml file under the script: section. That's because, previously, Travis itself was in charge of running our tests. Now, Tox will be in charge of doing...