diff options
Diffstat (limited to 'coverage')
-rw-r--r-- | coverage/data.py | 27 | ||||
-rw-r--r-- | coverage/results.py | 4 |
2 files changed, 22 insertions, 9 deletions
diff --git a/coverage/data.py b/coverage/data.py index 981edf8d..1c6a283a 100644 --- a/coverage/data.py +++ b/coverage/data.py @@ -86,17 +86,30 @@ class CoverageData(object): self._plugins = {} def lines(self, filename): - """Get the list of lines executed for a file.""" + """Get the list of lines executed for a file. + + If the file was not measured, returns None. A file might be measured, + and have no lines executed, in which case an empty list is returned. + + """ if self._arcs: - arcs = self._arcs.get(filename) or {} - return [s for s, __ in arcs if s > 0] + if filename in self._arcs: + return [s for s, __ in self._arcs[filename] if s > 0] else: - lines = self._lines.get(filename) or {} - return list(lines) + if filename in self._lines: + return list(self._lines[filename]) + return None def arcs(self, filename): - """Get the list of arcs executed for a file.""" - return list((self._arcs.get(filename) or {}).keys()) + """Get the list of arcs executed for a file. + + If the file was not measured, returns None. A file might be measured, + and have no arcs executed, in which case an empty list is returned. + + """ + if filename in self._arcs: + return list((self._arcs[filename]).keys()) + return None def plugin_name(self, filename): """Get the plugin name for a file. diff --git a/coverage/results.py b/coverage/results.py index 65e70c75..c7a2f95e 100644 --- a/coverage/results.py +++ b/coverage/results.py @@ -17,7 +17,7 @@ class Analysis(object): self.excluded = self.file_reporter.excluded_statements() # Identify missing statements. - executed = self.data.lines(self.filename) + executed = self.data.lines(self.filename) or [] executed = self.file_reporter.translate_lines(executed) self.missing = self.statements - executed @@ -61,7 +61,7 @@ class Analysis(object): def arcs_executed(self): """Returns a sorted list of the arcs actually executed in the code.""" - executed = self.data.arcs(self.filename) + executed = self.data.arcs(self.filename) or [] executed = self.file_reporter.translate_arcs(executed) return sorted(executed) |