summaryrefslogtreecommitdiff
path: root/coverage/data.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-07-19 16:50:47 -0400
committerNed Batchelder <ned@nedbatchelder.com>2015-07-19 16:50:47 -0400
commit48303301ee55ab3a780547e57cf4778841cafdb2 (patch)
tree1954765bbdc4ce6001f3c9204bc7185b1a273088 /coverage/data.py
parent2f6601bd71f2f90f095d0f70ae315c666c635ed8 (diff)
downloadpython-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.py27
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.