Skip to content

Commit

Permalink
move pytest coverage and parallelization to tox
Browse files Browse the repository at this point in the history
* enables more usable/debuggable direct runs of pytest without changing config
* also fixed `posargs` default behavior on unit env to match the others
  • Loading branch information
nitzmahone committed Apr 27, 2023
1 parent 613f24f commit c148044
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
5 changes: 0 additions & 5 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ addopts =
--color yes
--showlocals
--verbose
--numprocesses auto
--durations 10
--durations-min 1
--strict-markers
--cov
--cov-report html
--cov-report term
--cov-report xml
15 changes: 9 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
envlist = linters, unit
isolated_build = True

[shared]
pytest_cov_args = --cov --cov-report html --cov-report term --cov-report xml

[testenv]
description = Run all tests with {basepython}
usedevelop = True
deps =
-r {toxinidir}/test/requirements.txt
commands = pytest {posargs}
commands = pytest -n auto {posargs}

[testenv:linters{,-py39,-py310,-py311}]
description = Run code linters
Expand All @@ -20,15 +23,15 @@ commands =

[testenv:unit{,-py39,-py310,-py311}]
description = Run unit tests
commands = pytest {posargs:test/unit}
commands = pytest -n auto test/unit {posargs} {[shared]pytest_cov_args}

[testenv:pulp-integration{-py39,-py310,-py311}]
# Some of these tests must run serially because of a shared resource
# (the system policy.json file).
description = Run pulp integration tests
commands =
pytest -n 0 -m "serial" test/pulp_integration {posargs}
pytest -m "not serial" test/pulp_integration {posargs}
pytest -n auto -m "not serial" test/pulp_integration {posargs} {[shared]pytest_cov_args}
pytest -n 0 -m "serial" test/pulp_integration {posargs} {[shared]pytest_cov_args}

[testenv:integration{,-py39,-py310,-py311}]
description = Run integration tests
Expand All @@ -37,8 +40,8 @@ passenv =
HOME
KEEP_IMAGES
commands =
pytest -m "not serial" test/integration {posargs}
pytest -n 0 -m "serial" test/integration {posargs}
pytest -n auto -m "not serial" test/integration {posargs} {[shared]pytest_cov_args}
pytest -n 0 -m "serial" test/integration {posargs} {[shared]pytest_cov_args}

[testenv:docs]
description = Build documentation
Expand Down

0 comments on commit c148044

Please sign in to comment.