From c317727542e303ae9dd5ed4db73217508e367d74 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 8 Jul 2014 06:25:17 -0400 Subject: Improve branch summarization It failed completely on more than one file! Removed the Branches label, and no longer report missing branches implied by missing lines. --- coverage/results.py | 10 ++++++---- coverage/summary.py | 13 ++++++------- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'coverage') diff --git a/coverage/results.py b/coverage/results.py index c9034bcd..6cbcbfc8 100644 --- a/coverage/results.py +++ b/coverage/results.py @@ -84,18 +84,20 @@ class Analysis(object): return sorted(missing) def arcs_missing_formatted(self): - """ The missing branch arcs, formatted. + """ The missing branch arcs, formatted nicely. - Returns a string like "1->2, 1->3, 16->20" + Returns a string like "1->2, 1->3, 16->20". Omits any mention of + missing lines, so if line 17 is missing, then 16->17 won't be included. """ arcs = self.missing_branch_arcs() + missing = self.missing line_exits = sorted(iitems(arcs)) pairs = [] for line, exits in line_exits: for ex in sorted(exits): - pair = '%d->%d' % (line, ex) - pairs.append(pair) + if line not in missing and ex not in missing: + pairs.append('%d->%d' % (line, ex)) return ', '.join(pairs) def arcs_unpredicted(self): diff --git a/coverage/summary.py b/coverage/summary.py index 1e55a7d4..a6768cf9 100644 --- a/coverage/summary.py +++ b/coverage/summary.py @@ -37,8 +37,6 @@ class SummaryReporter(Reporter): if self.config.show_missing: header += " Missing" fmt_coverage += " %s" - if self.branches: - fmt_coverage += "%sBranches: %s" rule = "-" * len(header) + "\n" header += "\n" fmt_coverage += "\n" @@ -62,12 +60,13 @@ class SummaryReporter(Reporter): args += (nums.pc_covered_str,) if self.config.show_missing: missing_fmtd = analysis.missing_formatted() - args += (missing_fmtd,) if self.branches: - separator = "" - if missing_fmtd: - separator = ", " - args += (separator, analysis.arcs_missing_formatted(),) + branches_fmtd = analysis.arcs_missing_formatted() + if branches_fmtd: + if missing_fmtd: + missing_fmtd += ", " + missing_fmtd += branches_fmtd + args += (missing_fmtd,) outfile.write(fmt_coverage % args) total += nums except KeyboardInterrupt: # pragma: not covered -- cgit v1.2.1