-
Notifications
You must be signed in to change notification settings - Fork 17
Fix branch coverage rate comparison when used with --branch
without actual branches
#37
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
smarie
merged 5 commits into
smarie:main
from
marcegeek:coverage-branch-without-branches
Mar 26, 2025
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ff683ac
Fixed branch coverage rate comparison when `--branch` option is set b…
marcegeek 5679bb4
Merge branch 'main' into coverage-branch-without-branches
marcegeek eff718f
Added a test for a coverage file when the `--branch` option is set bu…
marcegeek b6b04bd
Fixed branch coverage rate computation to take `--branch` vs `--no-br…
marcegeek 410aa4a
Updated coverage test file for the `--branch` option without branches
marcegeek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
tests/reports/coverage/coverage_branch_without_branches.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" ?> | ||
<coverage version="7.6.1" timestamp="1725577267091" lines-valid="4" lines-covered="3" line-rate="0.75" branches-valid="0" branches-covered="0" branch-rate="1" complexity="0"> | ||
<!-- Generated by coverage.py: https://coverage.readthedocs.io/en/7.6.1 --> | ||
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd --> | ||
<sources> | ||
<source>/home/marce_geek/UTN/4/Agiles/python-actions-test</source> | ||
marcegeek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</sources> | ||
<packages> | ||
<package name="." line-rate="0.75" branch-rate="1" complexity="0"> | ||
<classes> | ||
<class name="mymodule.py" filename="mymodule.py" complexity="0" line-rate="0.75" branch-rate="1"> | ||
<methods/> | ||
<lines> | ||
<line number="1" hits="1"/> | ||
<line number="2" hits="1"/> | ||
<line number="5" hits="1"/> | ||
<line number="6" hits="0"/> | ||
</lines> | ||
</class> | ||
</classes> | ||
</package> | ||
</packages> | ||
</coverage> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nitpick)
If
branch_option
is only computed based on the other two fields according to this formula, could we implement it as a@property
instead of a field ? That way it would not need to be present in the constructor arguments, nor to be late-set here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure, as
cov.branch_rate
is computed as a@property
while the originalbranch-rate="1"
andbranches-valid="0"
fields from the XML are what we need to discover whether the--branch
option was set or not. Wouldn't that require to store the originalbranch_rate
from the XML? As a_branch_rate
/_original_branch_rate
/_xml_branch_rate
field maybe?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh I see your point. And I see that
CoverageStats
was already entirely implemented in this weird "init as none - then fill" pattern. I do not remember where this class was copied from but indeed making it "nice" would require to change all of it, not just this new feature.Not worth the effort IMO :) let's keep it like this for now.