Skip to content
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

Fix branch coverage rate comparison when used with --branch without actual branches #37

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
7 changes: 5 additions & 2 deletions genbadge/utils_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,11 @@ def parse_root(self, root):
line_rate = float(root.attrib.get('line-rate'))

if not is_close(cov.branch_rate, branch_rate):
raise ValueError("Computed branch rate (%s) is different from the one in the file (%s)"
% (cov.branch_rate, branch_rate))
# if branch=true but there are no actual branches coverage will report
# branches-valid="0" and branch-rate="1"
if cov.branches_valid != 0 or branch_rate != 1.0:
raise ValueError("Computed branch rate (%s) is different from the one in the file (%s)"
% (cov.branch_rate, branch_rate))
if not is_close(cov.line_rate, line_rate):
raise ValueError("Computed line rate (%s) is different from the one in the file (%s)"
% (cov.line_rate, line_rate))
Expand Down
Loading