Skip to content

Add missing lines-covered and lines-valid attributes #17738

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mypy/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,8 @@ def on_finish(self) -> None:
self.root_package.covered_lines, self.root_package.total_lines
)
self.root.attrib["branch-rate"] = "0"
self.root.attrib["lines-covered"] = str(self.root_package.covered_lines)
self.root.attrib["lines-valid"] = str(self.root_package.total_lines)
sources = etree.SubElement(self.root, "sources")
source_element = etree.SubElement(sources, "source")
source_element.text = os.getcwd()
Expand Down
4 changes: 2 additions & 2 deletions test-data/unit/reports.test
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def bar() -> str:
def untyped_function():
return 42
[outfile build/cobertura.xml]
<coverage timestamp="$TIMESTAMP" version="$VERSION" line-rate="0.7500" branch-rate="0">
<coverage timestamp="$TIMESTAMP" version="$VERSION" line-rate="0.7500" branch-rate="0" lines-covered="6" lines-valid="8">
<sources>
<source>$PWD</source>
</sources>
Expand Down Expand Up @@ -81,7 +81,7 @@ def foo(a: int) -> MyDict:
return {"a": a}
md: MyDict = MyDict(**foo(42))
[outfile build/cobertura.xml]
<coverage timestamp="$TIMESTAMP" version="$VERSION" line-rate="1.0000" branch-rate="0">
<coverage timestamp="$TIMESTAMP" version="$VERSION" line-rate="1.0000" branch-rate="0" lines-covered="6" lines-valid="6">
<sources>
<source>$PWD</source>
</sources>
Expand Down
Loading