Python Coverage Analysis warning

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 '' 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 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
source = 

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.


@ Andrea_Guarino

BUMP Adrea

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.

source = 

Could you please share coverage-reports/coverage-report.xml?


Seems that using source in .coveragerc generates a bad formated coverage-report.xml.
Switching to include fixes it and generates the correct xml.

include = 

Hope it helps.


1 Like