Skip to content

Commit

Permalink
Store relative file paths in the data file
Browse files Browse the repository at this point in the history
By default, coverage data contains absolute paths for the test suite. During CI,
coverage data from various runners is combined in an environment where these
paths do not exist. This results in errors like the following:

  No source for code:
  '/Users/runner/work/cookiecutter-hypermodern-python-instance/cookiecutter-hypermodern-python-instance/tests/__init__.py'.
  Aborting report output, consider using -i.

The `coverage.paths` setting does not help with the test suite: Unlike the code
under `src`, the test suite is not installed to `site-packages`, so we'd need to
either hardcode paths from individual runners, or use overly generic wildcards.

Instead, `coverage.run.relative_files` can be used to store the paths relative
to the repository. We still need `coverage.paths` for `src` though, because
these file paths still include the path into the various Nox environments.
  • Loading branch information
cjolowicz committed Nov 22, 2021
1 parent 3ec76fa commit 97722cd
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Expand Up @@ -52,6 +52,7 @@ source = ["src", "*/site-packages"]

[tool.coverage.run]
branch = true
relative_files = true
source = ["cookiecutter_hypermodern_python_instance", "tests"]

[tool.coverage.report]
Expand Down

0 comments on commit 97722cd

Please sign in to comment.