diff -r f1cbc18f88b2 -r fac17a82b431 DebugClients/Python3/coverage/summary.py --- a/DebugClients/Python3/coverage/summary.py Fri Apr 04 22:57:07 2014 +0200 +++ b/DebugClients/Python3/coverage/summary.py Thu Apr 10 23:02:20 2014 +0200 @@ -4,33 +4,37 @@ from .report import Reporter from .results import Numbers +from .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, omit_prefixes=None, outfile=None): - """Writes a report summarizing coverage statistics per module.""" + def report(self, morfs, outfile=None): + """Writes a report summarizing coverage statistics per module. - self.find_code_units(morfs, omit_prefixes) + `outfile` is a file object to write the summary to. + + """ + self.find_code_units(morfs) # Prepare the formatting strings max_name = max([len(cu.name) for cu in self.code_units] + [5]) fmt_name = "%%- %ds " % max_name fmt_err = "%s %s: %s\n" - header = (fmt_name % "Name") + " Stmts Exec" + header = (fmt_name % "Name") + " Stmts Miss" fmt_coverage = fmt_name + "%6d %6d" if self.branches: - header += " Branch BrExec" + header += " Branch BrMiss" fmt_coverage += " %6d %6d" - header += " Cover" - fmt_coverage += " %5d%%" - if self.show_missing: + width100 = Numbers.pc_str_width() + header += "%*s" % (width100+4, "Cover") + fmt_coverage += "%%%ds%%%%" % (width100+3,) + if self.config.show_missing: header += " Missing" fmt_coverage += " %s" rule = "-" * len(header) + "\n" @@ -50,27 +54,33 @@ try: analysis = self.coverage._analyze(cu) nums = analysis.numbers - args = (cu.name, nums.n_statements, nums.n_executed) + args = (cu.name, nums.n_statements, nums.n_missing) if self.branches: - args += (nums.n_branches, nums.n_executed_branches) - args += (nums.pc_covered,) - if self.show_missing: + args += (nums.n_branches, nums.n_missing_branches) + args += (nums.pc_covered_str,) + if self.config.show_missing: args += (analysis.missing_formatted(),) outfile.write(fmt_coverage % args) total += nums - except KeyboardInterrupt: #pragma: no cover + except KeyboardInterrupt: # pragma: not covered raise except: - if 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(): + report_it = False + if report_it: outfile.write(fmt_err % (cu.name, typ.__name__, msg)) if total.n_files > 1: outfile.write(rule) - args = ("TOTAL", total.n_statements, total.n_executed) + args = ("TOTAL", total.n_statements, total.n_missing) if self.branches: - args += (total.n_branches, total.n_executed_branches) - args += (total.pc_covered,) - if self.show_missing: + args += (total.n_branches, total.n_missing_branches) + args += (total.pc_covered_str,) + if self.config.show_missing: args += ("",) - outfile.write(fmt_coverage % args) \ No newline at end of file + outfile.write(fmt_coverage % args) + + return total.pc_covered