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

Use the Original percent_covered #361

13 changes: 7 additions & 6 deletions coverage_comment/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,11 @@ def extract_info(data: dict, coverage_path: pathlib.Path) -> Coverage:
info=CoverageInfo(
covered_lines=file_data["summary"]["covered_lines"],
num_statements=file_data["summary"]["num_statements"],
percent_covered=compute_coverage(
file_data["summary"]["covered_lines"],
file_data["summary"]["num_statements"],
percent_covered=decimal.Decimal(
str(
round(file_data["summary"]["percent_covered"], ndigits=2)
/ 100
)
),
missing_lines=file_data["summary"]["missing_lines"],
excluded_lines=file_data["summary"]["excluded_lines"],
Expand All @@ -213,9 +215,8 @@ def extract_info(data: dict, coverage_path: pathlib.Path) -> Coverage:
info=CoverageInfo(
covered_lines=data["totals"]["covered_lines"],
num_statements=data["totals"]["num_statements"],
percent_covered=compute_coverage(
data["totals"]["covered_lines"],
data["totals"]["num_statements"],
percent_covered=decimal.Decimal(
str(round(data["totals"]["percent_covered"], ndigits=2) / 100)
),
missing_lines=data["totals"]["missing_lines"],
excluded_lines=data["totals"]["excluded_lines"],
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def checker(payload):
assert comment == comment_file
assert comment == summary_file.read_text()
assert (
"Coverage for the whole project is 77.77%. Previous coverage rate is not available"
"Coverage for the whole project is 77.78%. Previous coverage rate is not available"
in comment
)
assert (
Expand Down Expand Up @@ -331,7 +331,7 @@ def checker(payload):
assert result == 0

assert not pathlib.Path("python-coverage-comment-action.txt").exists()
assert "Coverage for the whole project went from 30% to 77.77%" in comment
assert "Coverage for the whole project went from 30% to 77.78%" in comment
assert comment.count("<img") == 10
assert comment == summary_file.read_text()

Expand Down Expand Up @@ -402,7 +402,7 @@ def checker(payload):
assert result == 0

assert not pathlib.Path("python-coverage-comment-action.txt").exists()
assert "Coverage for the whole project went from 30% to 77.77%" in comment
assert "Coverage for the whole project went from 30% to 77.78%" in comment
assert comment == summary_file.read_text()

expected_output = "COMMENT_FILE_WRITTEN=false\n"
Expand Down
Loading