Is it possible to do the following using a single tox virtual environment?
[tox]
envlist = test, pylint, flake8, mypy
skipsdist = true
[testenv:lint]
deps = pylint
commands = pylint .
[testenv:flake8]
deps = flake8
commands = flake8 .
[testenv:mypy]
commands = mypy . --strict
[testenv:test]
deps = pytest
commands = pytest
As I am only testing on my python version (py3.7), I don't want tox to have to create 4 environments ( .tox/test
, .tox/pylint
, .tox/flake8
, .tox/mypy
) when they could all be run on a single environment.
I also want to see what failed individually individually, thus don't want to do:
[tox]
skipsdist = true
[testenv]
commands = pylint .
flake8 .
mypy . --strict
pytest
as the output would be like this:
_____________ summary ___________
ERROR: python: commands failed
and not like this:
____________________summary _________________
ERROR: test: commands failed
ERROR: lint: commands failed
ERROR: mypy: commands failed
test: commands succeeded
Two approaches come to mind:
envdir
so that there's little work to be done when "building" the virtualenv for the test environments successively:[testenv:lint]
envdir = {toxworkdir}/.work_env
deps = pylint
commands = pylint .
[testenv:flake8]
envdir = {toxworkdir}/.work_env
deps = flake8
commands = flake8 .
[testenv:mypy]
envdir = {toxworkdir}/.work_env
commands = mypy . --strict
[testenv:test]
envdir = {toxworkdir}/.work_env
deps = pytest
commands = pytest
[testenv:{lint,flake8,mypy,test}]
envdir = {toxworkdir}/.work_env
deps = pylint, flake8, pytest
commands =
lint: pylint .
flake8: flake8 .
mypy: mypy . --strict
test: pytest
tox
stops at the first failed command. So my recommendation is to order commands from fasterst to slowest and allow tox
to do the rest:
[testenv]
commands =
flake8 .
pylint .
mypy . --strict
pytest
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.