Must-share information (formatted with Markdown):
- SonarQube Developer Edition Version 9.4 (build 54424)
- Trying to get accurate coverage in python
I am getting this warning… Do you know how to fix it?
The following error(s) occurred while trying to import coverage report:
Cannot resolve the file path '__init__.py' of the coverage report, ambiguity, the file exists in several 'source'.%nCannot resolve 5 file paths, ignoring coverage measures for those files
hey @adric1 ,
Welcome to our community!
It looks like the coverage report contains 5 file having just
__init__.py as file path, so the analyzer is not able to tell what files it’s referring to.
Could you please share with us how you generate coverage report?
Hey! Thanks for the response:
We have this .coveragerc config file:
branch = True
skip_covered = True
output = coverage-reports/coverage-report.xml
And we launch the pytest with the following command:
pytest --cov -n 4 --cov-report xml --junitxml=xunit-reports/junit-report.xml
Seems to work properly, but for some reason we get that warning.
hi @adric1 ,
Sorry for late reply. Is it expected to have also
tests as source in
.coveragerc? If I’m not mistaken this means test files are also taken into account in coverage computation.
Could you please share
Seems that using
.coveragerc generates a bad formated
include fixes it and generates the correct xml.
Hope it helps.