Skip to content

Commit

Permalink
Update get_total() to support Coverage 7.5 (#28)
Browse files Browse the repository at this point in the history
In Coverage 7.5, the `display_covered` method of Numbers was turned into a standalone function, so the `get_total()` method stopped working.

Fixes #29.
  • Loading branch information
danielpodrazka authored Apr 24, 2024
1 parent db8de11 commit e630be8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion coverage_badge/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,16 @@ def pc_covered(self):
return self.percent

return Precision(total).pc_covered_str
else: # Coverage 6.x
elif hasattr(coverage.results.Numbers, 'display_covered'): # Coverage 6.x < 7.5
# NOTE: Precision is no longer set globally in the
# `coverage.results.Numbers` class. Instead the precision must be
# passed in as the first argument. We pull the precision from the
# `coverage.Coverage` object because it should pull the correct
# precision from the local .coveragerc file.
return coverage.results.Numbers(precision=cov.config.precision).display_covered(total)
else: # Coverage >= 7.5
return coverage.results.display_covered(total, cov.config.precision)



def get_color(total):
Expand Down

0 comments on commit e630be8

Please sign in to comment.