Skip to content

Commit

Permalink
tests: Remove various unneeded coverage workarounds
Browse files Browse the repository at this point in the history
Tests now run from root dir so various coverage complications
can be removed.

Also remove the duplicate .coveragerc and rely on pyproject.toml

Signed-off-by: Jussi Kukkonen <[email protected]>
  • Loading branch information
jku committed Dec 10, 2024
1 parent 19bc46f commit cbe09da
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 25 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: ${{ runner.os }} / Python ${{ matrix.python-version }}
COVERALLS_PARALLEL: true
# Use cp workaround to publish coverage reports with relative paths
# FIXME: Consider refactoring the tests to not require the test
# aggregation script being invoked from the `tests` directory, so
# that `.coverage` is written to and .coveragrc can also reside in
# the project root directory as is the convention.
run: |
cp tests/.coverage .
coveralls --service=github --rcfile=tests/.coveragerc
coveralls --service=github
coveralls-fin:
# Always run when all 'tests' jobs have finished even if they failed
Expand Down
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ include = [
"/setup.py",
]

[tool.hatch.build.targets.wheel]
# The testing phase changes the current working directory to `tests` but the test scripts import
# from `tests` so the root directory must be added to Python's path for editable installations
dev-mode-dirs = ["."]

# Ruff section
# Read more here: https://docs.astral.sh/ruff/linter/#rule-selection
[tool.ruff]
Expand Down Expand Up @@ -153,4 +158,8 @@ exclude_also = [
"raise AssertionError",
# imports for mypy only
"if TYPE_CHECKING",
]
[tool.coverage.run]
omit = [
"tests/*",
]
13 changes: 0 additions & 13 deletions tests/.coveragerc

This file was deleted.

7 changes: 2 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ skipsdist = true
commands =
python3 --version
python3 -m coverage run -m unittest
python3 -m coverage report --rcfile {toxinidir}/pyproject.toml -m --fail-under 97
python3 -m coverage report -m --fail-under 97

deps =
-r{toxinidir}/requirements/test.txt
Expand All @@ -33,10 +33,9 @@ commands_pre =

commands =
python3 -m coverage run -m unittest
python3 -m coverage report --rcfile {toxinidir}/pyproject.toml -m
python3 -m coverage report -m

[testenv:lint]
changedir = {toxinidir}
deps =
-r{toxinidir}/requirements/lint.txt
--editable {toxinidir}
Expand All @@ -49,7 +48,6 @@ commands =
mypy {[testenv:lint]lint_dirs}

[testenv:fix]
changedir = {toxinidir}
deps = {[testenv:lint]deps}
commands =
ruff check --fix {[testenv:lint]lint_dirs}
Expand All @@ -59,6 +57,5 @@ commands =
deps =
-r{toxinidir}/requirements/docs.txt

changedir = {toxinidir}
commands =
sphinx-build -b html docs docs/build/html -W

0 comments on commit cbe09da

Please sign in to comment.