Open
Description
Describe the bug
In the generated coverage.xml report the tag is not populating the sources path.
To Reproduce
What version of Python are you using?
python = 3.11
pytest = 4.0.0
coverage.py >= 7.0.0
.coveragerc file
[run]
source = app
omit =
# Ignore tests directory in coverage calculation
app/app/tests/*
app/tests/*
*__init__*
branch = True
relative_files = True
[report]
# Regexes for lines to exclude from consideration
exclude_lines =
pragma: no cover
def __repr__
if self\.debug
raise AssertionError
raise NotImplementedError
if __name__ == .__main__.:
ignore_errors = True
[html]
directory = coverage_html_report
Running with command
pytest --cov=app --cov-config=.coveragerc --cov-report=term-missing
Actual behavior
<?xml version="1.0" ?>
<coverage version="7.1.0" timestamp="1675848032023" lines-valid="2011" lines-covered="1913" line-rate="0.9513" branches-valid="444" branches-covered="375" branch-rate="0.8446" complexity="0">
<!-- Generated by coverage.py: https://coverage.readthedocs.io -->
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
<sources>
<source></source>
</sources>
<packages>
<package name="alembic" line-rate="0.8571" branch-rate="0.75" complexity="0">
<classes>
<class name="conftest.py" filename="alembic/conftest.py" complexity="0" line-rate="0.9091" branch-rate="1">
<methods/>
<lines>
<line number="1" hits="1"/>
<line number="2" hits="1"/>
<line number="3" hits="1"/>
<line number="4" hits="1"/>
<line number="7" hits="1"/>
<line number="8" hits="1"/>
<line number="10" hits="1"/>
<line number="11" hits="1" branch="true" condition-coverage="100% (2/2)"/>
<line number="12" hits="0"/>
<line number="13" hits="0"/>
<line number="16" hits="1"/>
<line number="17" hits="1"/>
<line number="18" hits="1"/>
<line number="19" hits="1"/>
Expected behavior
<?xml version="1.0" ?>
<coverage version="6.5.0" timestamp="1675984773687" lines-valid="2042" lines-covered="1945" line-rate="0.9525" branches-valid="452" branches-covered="385" branch-rate="0.8518" complexity="0">
<!-- Generated by coverage.py: https://coverage.readthedocs.io -->
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
<sources>
<source>/home/runner/work/contract-service/contract-service/app</source>
</sources>
<packages>
<package name="alembic" line-rate="0.8571" branch-rate="0.75" complexity="0">
<classes>
<class name="conftest.py" filename="alembic/conftest.py" complexity="0" line-rate="0.9091" branch-rate="1">
<methods/>
<lines>
<line number="1" hits="1"/>
<line number="2" hits="1"/>
<line number="3" hits="1"/>
<line number="4" hits="1"/>
<line number="7" hits="1"/>
<line number="8" hits="1"/>
<line number="10" hits="1"/>
<line number="11" hits="1" branch="true" condition-coverage="100% (2/2)"/>
Additional context
This issue is only happening for all coverage.py versions >= 7.0.0 where I cannot get the sources path to display in the coverage.xml file. The tests are running in docker containers.