Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include test suite in code coverage #870

Closed
wants to merge 2 commits into from

Commits on Apr 15, 2021

  1. Include test suite in code coverage

    Rationale:
    
    - Tests are code.
    - Identify tests that aren’t running.
    - Ensure that test helpers are used and tested.
    
    Caveats:
    
    - Coverage may require extra configuration if tests are deliberately excluded.
    - Tests may clutter the coverage report; use `--skip-covered` for this.
    - The coverage metric generally goes up.
    
    https://nedbatchelder.com/blog/202008/you_should_include_your_tests_in_coverage.html
    cjolowicz committed Apr 15, 2021
    Configuration menu
    Copy the full SHA
    c209721 View commit details
    Browse the repository at this point in the history
  2. Store relative file paths in the data file

    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.
    cjolowicz committed Apr 15, 2021
    Configuration menu
    Copy the full SHA
    eb31214 View commit details
    Browse the repository at this point in the history