Coverage report for python shows module ignored in .coveragerc


(Pavel Savchenko) #1

Hi all,

This is a question to SonarCloud people,

My .coveragerc configuration includes:

omit =

Here’s the reference docs:

I have confirmed that the resulting cobertura formatted xml file excludes these tests folders, and any files in them, from the coverage report. We upload them to sonar cloud during a CI pipeline build, and the logs show:

INFO: Python test coverage
INFO: Parsing report '/opt/atlassian/pipelines/agent/build/coverage.xml'
INFO: Sensor Cobertura Sensor for Python coverage [python] (done) | time=161ms
INFO: Sensor PythonXUnitSensor [python]
INFO: Sensor PythonXUnitSensor [python] (done) | time=18ms

I believe I could add this “omit” pattern to ignore test files in our sonar cloud configuration, but that feels redundant, as the coverage.xml file clearly excludes them … maybe we have some sort of cached coverage report for these files? Is there a way to clear it?

Thanks a lot,

(Andrea Guarino) #3

Hi @asfaltboy,

Welcome to SonarSource community.
We don’t automatically exclude files that are not present in coverage.xml.

However, as you want to exclude tests files from coverage, I’d suggest to declare those files as being “test files” by using sonar.tests analysis parameter.