diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-11-02 11:10:19 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-11-02 11:10:19 -0500 |
commit | f6bc21ddee35703d80914d245f06ee5ce594eb97 (patch) | |
tree | 6bc33549d11dc4d1d830344e81b5501ded61d936 /coverage/results.py | |
parent | 467eb680940b8653667751f4232a3d46f61d8350 (diff) | |
download | python-coveragepy-git-f6bc21ddee35703d80914d245f06ee5ce594eb97.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.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/coverage/results.py b/coverage/results.py index 41102595..ec59482d 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 |