summaryrefslogtreecommitdiff
path: root/coverage/results.py
diff options
context:
space:
mode:
Diffstat (limited to 'coverage/results.py')
-rw-r--r--coverage/results.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/coverage/results.py b/coverage/results.py
index 6c41a94..5eff0f3 100644
--- a/coverage/results.py
+++ b/coverage/results.py
@@ -204,8 +204,8 @@ class Numbers(object):
def pc_covered(self):
"""Returns a single percentage value for coverage."""
if self.n_statements > 0:
- pc_cov = (100.0 * (self.n_executed + self.n_executed_branches) /
- (self.n_statements + self.n_branches))
+ numerator, denominator = self.ratio_covered
+ pc_cov = (100.0 * numerator) / denominator
else:
pc_cov = 100.0
return pc_cov
@@ -236,6 +236,13 @@ class Numbers(object):
width += 1 + cls._precision
return width
+ @property
+ def ratio_covered(self):
+ """Return a numerator and denominator for the coverage ratio."""
+ numerator = self.n_executed + self.n_executed_branches
+ denominator = self.n_statements + self.n_branches
+ return numerator, denominator
+
def __add__(self, other):
nums = Numbers()
nums.n_files = self.n_files + other.n_files