diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2015-07-19 16:50:47 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2015-07-19 16:50:47 -0400 |
commit | 48303301ee55ab3a780547e57cf4778841cafdb2 (patch) | |
tree | 1954765bbdc4ce6001f3c9204bc7185b1a273088 /coverage/data.py | |
parent | 2f6601bd71f2f90f095d0f70ae315c666c635ed8 (diff) | |
download | python-coveragepy-48303301ee55ab3a780547e57cf4778841cafdb2.tar.gz |
CoverageData.lines() and CoverageData.arcs() now distinguish between unmeasured, and measured, but nothing ran
Diffstat (limited to 'coverage/data.py')
-rw-r--r-- | coverage/data.py | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/coverage/data.py b/coverage/data.py index 981edf8..1c6a283 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. |