diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml index ba125e3124..76a8afbb01 100644 --- a/.github/workflows/_test.yml +++ b/.github/workflows/_test.yml @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 573ebf0254..7f56643910 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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] @@ -153,4 +158,8 @@ exclude_also = [ "raise AssertionError", # imports for mypy only "if TYPE_CHECKING", +] +[tool.coverage.run] +omit = [ + "tests/*", ] \ No newline at end of file diff --git a/tests/.coveragerc b/tests/.coveragerc deleted file mode 100644 index 1fa2203580..0000000000 --- a/tests/.coveragerc +++ /dev/null @@ -1,13 +0,0 @@ -[run] -branch = True - -omit = - */tests/* - */site-packages/* - -[report] -exclude_lines = - pragma: no cover - def __str__ - if __name__ == .__main__.: - @abstractmethod diff --git a/tox.ini b/tox.ini index 63049b5077..aa20ae1daf 100644 --- a/tox.ini +++ b/tox.ini @@ -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 @@ -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} @@ -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} @@ -59,6 +57,5 @@ commands = deps = -r{toxinidir}/requirements/docs.txt -changedir = {toxinidir} commands = sphinx-build -b html docs docs/build/html -W