28 self._arc_possibilities = sorted(self.file_reporter.arcs()) |
28 self._arc_possibilities = sorted(self.file_reporter.arcs()) |
29 self.exit_counts = self.file_reporter.exit_counts() |
29 self.exit_counts = self.file_reporter.exit_counts() |
30 self.no_branch = self.file_reporter.no_branch_lines() |
30 self.no_branch = self.file_reporter.no_branch_lines() |
31 n_branches = self.total_branches() |
31 n_branches = self.total_branches() |
32 mba = self.missing_branch_arcs() |
32 mba = self.missing_branch_arcs() |
33 n_partial_branches = sum( |
33 n_partial_branches = sum(len(v) for k,v in iitems(mba) if k not in self.missing) |
34 len(v) for k,v in iitems(mba) if k not in self.missing |
|
35 ) |
|
36 n_missing_branches = sum(len(v) for k,v in iitems(mba)) |
34 n_missing_branches = sum(len(v) for k,v in iitems(mba)) |
37 else: |
35 else: |
38 self._arc_possibilities = [] |
36 self._arc_possibilities = [] |
39 self.exit_counts = {} |
37 self.exit_counts = {} |
40 self.no_branch = set() |
38 self.no_branch = set() |
46 n_excluded=len(self.excluded), |
44 n_excluded=len(self.excluded), |
47 n_missing=len(self.missing), |
45 n_missing=len(self.missing), |
48 n_branches=n_branches, |
46 n_branches=n_branches, |
49 n_partial_branches=n_partial_branches, |
47 n_partial_branches=n_partial_branches, |
50 n_missing_branches=n_missing_branches, |
48 n_missing_branches=n_missing_branches, |
51 ) |
49 ) |
52 |
50 |
53 def missing_formatted(self): |
51 def missing_formatted(self): |
54 """The missing line numbers, formatted nicely. |
52 """The missing line numbers, formatted nicely. |
55 |
53 |
56 Returns a string like "1-2, 5-11, 13-14". |
54 Returns a string like "1-2, 5-11, 13-14". |
82 and p[0] not in self.no_branch |
80 and p[0] not in self.no_branch |
83 ) |
81 ) |
84 return sorted(missing) |
82 return sorted(missing) |
85 |
83 |
86 def arcs_missing_formatted(self): |
84 def arcs_missing_formatted(self): |
87 """ The missing branch arcs, formatted nicely. |
85 """The missing branch arcs, formatted nicely. |
88 |
86 |
89 Returns a string like "1->2, 1->3, 16->20". Omits any mention of |
87 Returns a string like "1->2, 1->3, 16->20". Omits any mention of |
90 branches from missing lines, so if line 17 is missing, then 17->18 |
88 branches from missing lines, so if line 17 is missing, then 17->18 |
91 won't be included. |
89 won't be included. |
92 |
90 |
96 line_exits = sorted(iitems(arcs)) |
94 line_exits = sorted(iitems(arcs)) |
97 pairs = [] |
95 pairs = [] |
98 for line, exits in line_exits: |
96 for line, exits in line_exits: |
99 for ex in sorted(exits): |
97 for ex in sorted(exits): |
100 if line not in missing: |
98 if line not in missing: |
101 pairs.append('%d->%d' % (line, ex)) |
99 pairs.append("%d->%s" % (line, (ex if ex > 0 else "exit"))) |
102 return ', '.join(pairs) |
100 return ', '.join(pairs) |
103 |
101 |
104 def arcs_unpredicted(self): |
102 def arcs_unpredicted(self): |
105 """Returns a sorted list of the executed arcs missing from the code.""" |
103 """Returns a sorted list of the executed arcs missing from the code.""" |
106 possible = self.arc_possibilities() |
104 possible = self.arc_possibilities() |