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 | 8eec054f2e2c7b3f3669f28d382ddcfec39d48f0 (patch) | |
tree | b1b53f3c6a5d28c6eb52c39849445acdf71cebfc /coverage/data.py | |
parent | b2d9f2638cd7e53687401ea89ebaa446e6762512 (diff) | |
download | python-coveragepy-git-8eec054f2e2c7b3f3669f28d382ddcfec39d48f0.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 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. |