diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-11-02 10:08:32 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-11-02 10:08:32 -0500 |
commit | 2b3abb4f1bebe139fe413603672580c2110bdb00 (patch) | |
tree | 6a05b8ee78a2f8aa712b8817819015808c2593ab /coverage/summary.py | |
parent | fb07857ab135233de7dab547ddd75411a19d84cf (diff) | |
download | python-coveragepy-2b3abb4f1bebe139fe413603672580c2110bdb00.tar.gz |
A Numbers class to handle the interrelationships of counts and percentages, including in rolled-up presentations.
Diffstat (limited to 'coverage/summary.py')
-rw-r--r-- | coverage/summary.py | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/coverage/summary.py b/coverage/summary.py index 2a693b8..08e74b3 100644 --- a/coverage/summary.py +++ b/coverage/summary.py @@ -15,6 +15,7 @@ class SummaryReporter(Reporter): def report(self, morfs, omit_prefixes=None, outfile=None): """Writes a report summarizing coverage statistics per module.""" + from coverage.control import Numbers self.find_code_units(morfs, omit_prefixes) # Prepare the formatting strings @@ -35,23 +36,17 @@ class SummaryReporter(Reporter): outfile.write(header) outfile.write(rule) - total_statements = 0 - total_executed = 0 - total_units = 0 + total = Numbers() for cu in self.code_units: try: analysis = self.coverage._analyze(cu) - n = len(analysis.statements) - m = n - len(analysis.missing) - pc = analysis.percent_covered() - args = (cu.name, n, m, pc) + nums = analysis.numbers + args = (cu.name, nums.n_statements, nums.n_run, nums.percent_covered) if self.show_missing: args = args + (analysis.missing_formatted(),) outfile.write(fmt_coverage % args) - total_units += 1 - total_statements = total_statements + n - total_executed = total_executed + m + total += nums except KeyboardInterrupt: #pragma: no cover raise except: @@ -59,13 +54,9 @@ class SummaryReporter(Reporter): typ, msg = sys.exc_info()[:2] outfile.write(fmt_err % (cu.name, typ.__name__, msg)) - if total_units > 1: + if total.n_files > 1: outfile.write(rule) - if total_statements > 0: - pc = 100.0 * total_executed / total_statements - else: - pc = 100.0 - args = ("TOTAL", total_statements, total_executed, pc) + args = ("TOTAL", total.n_statements, total.n_run, total.percent_covered) if self.show_missing: args = args + ("",) outfile.write(fmt_coverage % args) |