diff options
Diffstat (limited to 'coverage/results.py')
-rw-r--r-- | coverage/results.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/coverage/results.py b/coverage/results.py index c1718d46..f15fae74 100644 --- a/coverage/results.py +++ b/coverage/results.py @@ -1,3 +1,6 @@ +# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 +# For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt + """Results of coverage measurement.""" import collections @@ -9,19 +12,19 @@ from coverage.misc import format_lines class Analysis(object): """The results of analyzing a FileReporter.""" - def __init__(self, cov, file_reporters): - self.coverage = cov + def __init__(self, data, file_reporters): + self.data = data self.file_reporter = file_reporters self.filename = self.file_reporter.filename self.statements = self.file_reporter.statements() self.excluded = self.file_reporter.excluded_statements() # Identify missing statements. - executed = self.coverage.data.executed_lines(self.filename) + executed = self.data.lines(self.filename) or [] executed = self.file_reporter.translate_lines(executed) self.missing = self.statements - executed - if self.coverage.data.has_arcs(): + if self.data.has_arcs(): self.no_branch = self.file_reporter.no_branch_lines() n_branches = self.total_branches() mba = self.missing_branch_arcs() @@ -53,7 +56,7 @@ class Analysis(object): def has_arcs(self): """Were arcs measured in this result?""" - return self.coverage.data.has_arcs() + return self.data.has_arcs() def arc_possibilities(self): """Returns a sorted list of the arcs in the code.""" @@ -61,7 +64,7 @@ class Analysis(object): def arcs_executed(self): """Returns a sorted list of the arcs actually executed in the code.""" - executed = self.coverage.data.executed_arcs(self.filename) + executed = self.data.arcs(self.filename) or [] executed = self.file_reporter.translate_arcs(executed) return sorted(executed) @@ -101,10 +104,13 @@ class Analysis(object): # Exclude arcs here which connect a line to itself. They can occur # in executed data in some cases. This is where they can cause # trouble, and here is where it's the least burden to remove them. + # Also, generators can somehow cause arcs from "enter" to "exit", so + # make sure we have at least one positive value. unpredicted = ( e for e in executed if e not in possible and e[0] != e[1] + and (e[0] > 0 or e[1] > 0) ) return sorted(unpredicted) |