summaryrefslogtreecommitdiff
path: root/coverage/summary.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2012-04-19 19:05:22 -0400
committerNed Batchelder <ned@nedbatchelder.com>2012-04-19 19:05:22 -0400
commitca739cdb76ca212c71732066f7823dc65c8e79af (patch)
treee97a68f543a505f35dcb9943e678587e427b5363 /coverage/summary.py
parent84f6580e6ba48e34485f017afea1b8f62824514a (diff)
downloadpython-coveragepy-ca739cdb76ca212c71732066f7823dc65c8e79af.tar.gz
Refactor reporters so the config is part of construction, and is then available everywhere.
Diffstat (limited to 'coverage/summary.py')
-rw-r--r--coverage/summary.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/coverage/summary.py b/coverage/summary.py
index dcd5b15..fec9481 100644
--- a/coverage/summary.py
+++ b/coverage/summary.py
@@ -10,19 +10,17 @@ from coverage.misc import NotPython
class SummaryReporter(Reporter):
"""A reporter for writing the summary report."""
- def __init__(self, coverage, show_missing=True, ignore_errors=False):
- super(SummaryReporter, self).__init__(coverage, ignore_errors)
- self.show_missing = show_missing
+ def __init__(self, coverage, config):
+ super(SummaryReporter, self).__init__(coverage, config)
self.branches = coverage.data.has_arcs()
- def report(self, morfs, outfile=None, config=None):
+ def report(self, morfs, outfile=None):
"""Writes a report summarizing coverage statistics per module.
- `outfile` is a file object to write the summary to. `config` is a
- CoverageConfig instance.
+ `outfile` is a file object to write the summary to.
"""
- self.find_code_units(morfs, config)
+ self.find_code_units(morfs)
# Prepare the formatting strings
max_name = max([len(cu.name) for cu in self.code_units] + [5])
@@ -36,7 +34,7 @@ class SummaryReporter(Reporter):
width100 = Numbers.pc_str_width()
header += "%*s" % (width100+4, "Cover")
fmt_coverage += "%%%ds%%%%" % (width100+3,)
- if self.show_missing:
+ if self.config.show_missing:
header += " Missing"
fmt_coverage += " %s"
rule = "-" * len(header) + "\n"
@@ -60,14 +58,14 @@ class SummaryReporter(Reporter):
if self.branches:
args += (nums.n_branches, nums.n_missing_branches)
args += (nums.pc_covered_str,)
- if self.show_missing:
+ if self.config.show_missing:
args += (analysis.missing_formatted(),)
outfile.write(fmt_coverage % args)
total += nums
except KeyboardInterrupt: # pragma: no cover
raise
except:
- report_it = not self.ignore_errors
+ report_it = not self.config.ignore_errors
if report_it:
typ, msg = sys.exc_info()[:2]
if typ is NotPython and not cu.should_be_python(".py"):
@@ -81,6 +79,6 @@ class SummaryReporter(Reporter):
if self.branches:
args += (total.n_branches, total.n_missing_branches)
args += (total.pc_covered_str,)
- if self.show_missing:
+ if self.config.show_missing:
args += ("",)
outfile.write(fmt_coverage % args)