Thanks to visit codestin.com
Credit goes to github.com

Skip to content

codecov not reporting expected coverage when using package name #2113

@jhlegarreta

Description

@jhlegarreta

Have you asked elsewhere?

Yes, I have asked the question on Python's discussion forum and the codecov feedback repository:

https://discuss.python.org/t/codecov-not-reporting-expected-coverage-when-using-package-name/105368

codecov/feedback#838

Unfortunately, after a few days, it does not look like anybody has been able to cast some light on the issue.

Describe your situation

What happened

I am working on a project called NiQuery hosted on GitHub. I am confused about the coverage report.

I was surprised to see that the module run.py has 0% coverage:
https://app.codecov.io/gh/nipreps/niquery/tree/main/src%2Fniquery%2Fcli

I thought that this may be related to the use of click commands by the run.py module, and some sort of interaction that I was missing between components, or the way things are imported. However, I have realized that there are such as filtering.py and featuring.py that do not depend on click for which the reported coverage is also 0%:
https://app.codecov.io/gh/nipreps/niquery/tree/main/src%2Fniquery%2Fanalysis

Again, they are extensively tested:
https://github.com/nipreps/niquery/blob/main/test/test_analysis_featuring.py
https://github.com/nipreps/niquery/blob/main/test/test_analysis_filtering.py

What you did

In the relevant command in my tox.ini file, if I change the package name for the location of the files for the cov option:

commands =
  pytest -sv --doctest-modules --cov niquery --cov-report xml \
  --junitxml=test-results.xml -v src test {posargs:-n auto}

to

commands =
  pytest -sv --doctest-modules --cov src/niquery --cov-report xml \
  --junitxml=test-results.xml -v src test {posargs:-n auto}

then the coverage increases significantly (from 0% to 82%, 98% and 100% for the files at issue.)

The behavior can also be reproduced simply calling pytest:

pytest --cov niquery

vs

pytest --cov src/niquery

How that was different than what you wanted to happen

I contribute to other projects that have a very similar structure and use the package name for the cov option and do not have this issues.

I would like to stick to the philosophy of using the package name for the cov option, unless this is wrong, as it is used by other projects within the organization.

What kind of help you need

I would like to know how I can make it such that the coverage is reported correctly while keeping the package name in the cov option of pytest.

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    supportA support question from a user

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions