Skip to content

Commit

Permalink
Merge pull request #21 from captainhammy/testing/tox-and-testing-impr…
Browse files Browse the repository at this point in the history
…ovements

test: improvements to tox setup and execution
  • Loading branch information
captainhammy authored Feb 9, 2024
2 parents 6f080ff + 44f0fa5 commit a956230
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 34 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[tool.pytest.ini_options]
# Disable sugar as it interferes with pytester output parsing.
addopts = "-p no:sugar --cov --cov-report=html --cov-report=xml --color=yes"
addopts = "-p no:sugar --cov --cov-report=html --cov-report=xml --cov-fail-under=100 --color=yes"

[tool.coverage]

Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
],
extras_require={
"test": [
"coverage",
"pytest-cov",
"tox",
]
Expand Down
51 changes: 19 additions & 32 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
[tox]
envlist = h20,ruff-check,ruff-format-check,isort-check,mypy,docstring-check
skipsdist = true
env_list = py310,ruff-check,ruff-format-check,isort-check,mypy,docstring-check
no_package = true
labels =
test = py310
static = ruff-check,ruff-format-check,isort-check,mypy,docstring-check
fix = ruff-format-run,isort-run,docstring-run

[gh-actions]
python =
Expand All @@ -9,53 +13,38 @@ python =

[testenv]
allowlist_externals=
coverage
echo
env
hython
deps =
.[test]
setenv =
# Extra args to pass to the Hython command. This is really only useful for local testing using
# my (Graham's) setup which relies on selecting the Houdini version via wrapper arg. When things
# are run automatically on Github the expected Houdini version is already sourced.
hython_extra=

pass_env=*
set_env =
# We need to explicitly setup the PYTHONPATH to include all the tox installed modules
# because hython will not load them by default, unlike if we were just using a standard
# Python interpreter.
PYTHONPATH = {envsitepackagesdir}
commands =
coverage erase
# We need to force in the tox env as we won't be using the created venv and thus won't get the
# packages added to the path.
env PYTHONPATH={envsitepackagesdir} hython {env:hython_extra} -m pytest tests/
coverage report --fail-under=100 --skip-covered

[testenv:h195]
basepython=py39
setenv =
hython_extra=--version 19.5

[testenv:h20]
basepython=py310
setenv =
hython_extra=--version 20.0
hython -m pytest tests/
echo "View test coverage report at file://{toxinidir}/coverage_html_report/index.html"

[testenv:ruff-check]
deps = ruff
commands = ruff check --preview src/ tests/

[testenv:ruff-format-check]
deps = ruff
deps = {[testenv:ruff-check]deps}
commands = ruff format --preview --check src/ tests/

[testenv:ruff-format-run]
deps = ruff
deps = {[testenv:ruff-check]deps}
commands = ruff format --preview src/ tests/

[testenv:isort-check]
deps = isort
commands = isort --check src/ tests/ setup.py

[testenv:isort-run]
deps = isort
deps = {[testenv:isort-check]deps}
commands = isort src/ tests/ setup.py

[testenv:mypy]
Expand All @@ -65,13 +54,11 @@ deps =
commands = mypy

[testenv:docstring-check]
deps =
pydocstringformatter
deps = pydocstringformatter
commands = pydocstringformatter --exit-code src/

[testenv:docstring-run]
deps =
pydocstringformatter
deps = {[testenv:docstring-check]deps}
commands = pydocstringformatter --write src/

[testenv:docs]
Expand Down

0 comments on commit a956230

Please sign in to comment.