summaryrefslogtreecommitdiff
path: root/coverage/results.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2009-11-02 11:10:19 -0500
committerNed Batchelder <ned@nedbatchelder.com>2009-11-02 11:10:19 -0500
commitb4b8a1e1d263982eed48892be6c9bb82742489ae (patch)
treebd133859dd56a5dcd73313ccfc00ec1152c7a1fe /coverage/results.py
parentfa2f16dd58a1859823bc4942cfc5ecdf8c6f87bd (diff)
downloadpython-coveragepy-b4b8a1e1d263982eed48892be6c9bb82742489ae.tar.gz
HTML reporting makes use of Numbers to simplify and centralize the code.
Diffstat (limited to 'coverage/results.py')
-rw-r--r--coverage/results.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/coverage/results.py b/coverage/results.py
index 4110259..ec59482 100644
--- a/coverage/results.py
+++ b/coverage/results.py
@@ -125,6 +125,7 @@ class Numbers(object):
self.n_missing = 0
def _get_n_run(self):
+ """Returns the number of executed statements."""
return self.n_statements - self.n_missing
n_run = property(_get_n_run)
@@ -137,9 +138,16 @@ class Numbers(object):
return pc_cov
percent_covered = property(_get_percent_covered)
- def __iadd__(self, other):
- self.n_files += other.n_files
- self.n_statements += other.n_statements
- self.n_excluded += other.n_excluded
- self.n_missing += other.n_missing
- return self
+ def __add__(self, other):
+ nums = Numbers()
+ nums.n_files = self.n_files + other.n_files
+ nums.n_statements = self.n_statements + other.n_statements
+ nums.n_excluded = self.n_excluded + other.n_excluded
+ nums.n_missing = self.n_missing + other.n_missing
+ return nums
+
+ def __radd__(self, other):
+ # Implementing 0+Numbers allows us to sum() a list of Numbers.
+ if other == 0:
+ return self
+ raise NotImplemented