diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2010-09-04 13:59:10 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2010-09-04 13:59:10 -0400 |
commit | 057d56dfdc92a13acbdd8bcba6048a5f794622fa (patch) | |
tree | db41b49c5055bc23856d678c4d6ee4342018b65f /coverage/results.py | |
parent | 62a2766fd6218180cd62aee67e92f272e44c45f0 (diff) | |
download | python-coveragepy-057d56dfdc92a13acbdd8bcba6048a5f794622fa.tar.gz |
The XML report was missing an attribute Cobertura needed. Fixes #65 and #81.
Diffstat (limited to 'coverage/results.py')
-rw-r--r-- | coverage/results.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/coverage/results.py b/coverage/results.py index e6e3942..85071fe 100644 --- a/coverage/results.py +++ b/coverage/results.py @@ -94,7 +94,7 @@ class Analysis(object): return sorted(unpredicted) def branch_lines(self): - """Returns lines that have more than one exit.""" + """Returns a list of line numbers that have more than one exit.""" exit_counts = self.parser.exit_counts() return [l1 for l1,count in exit_counts.items() if count > 1] @@ -119,6 +119,25 @@ class Analysis(object): mba[l1].append(l2) return mba + def branch_stats(self): + """Get stats about branches. + + Returns a dict mapping line numbers to a tuple: + (total_exits, taken_exits). + """ + + exit_counts = self.parser.exit_counts() + missing_arcs = self.missing_branch_arcs() + stats = {} + for lnum in self.branch_lines(): + exits = exit_counts[lnum] + try: + missing = len(missing_arcs[lnum]) + except KeyError: + missing = 0 + stats[lnum] = (exits, exits - missing) + return stats + class Numbers(object): """The numerical results of measuring coverage. |