summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-05-25 14:33:25 -0400
committerNed Batchelder <ned@nedbatchelder.com>2015-05-25 14:33:25 -0400
commitcc3a20140e4bd1472be4ce288a379c923ef6ff39 (patch)
tree4030060bbfd973725d59fb31ee48f4d997158539
parentda348524fbe58b6897ad3b592755dad19fc28f36 (diff)
downloadpython-coveragepy-cc3a20140e4bd1472be4ce288a379c923ef6ff39.tar.gz
Normalize measured data's filenames before adding to data.
-rw-r--r--coverage/control.py9
-rw-r--r--coverage/data.py4
-rw-r--r--tests/plugin2.py3
3 files changed, 12 insertions, 4 deletions
diff --git a/coverage/control.py b/coverage/control.py
index defba56..574c874 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -754,10 +754,13 @@ class Coverage(object):
if not self._measured:
return
+ def abs_file_dict(d):
+ return dict((abs_file(k), v) for k,v in iitems(d))
+
# TODO: seems like this parallel structure is getting kinda old...
- self.data.add_line_data(self.collector.get_line_data())
- self.data.add_arc_data(self.collector.get_arc_data())
- self.data.add_plugin_data(self.collector.get_plugin_data())
+ self.data.add_line_data(abs_file_dict(self.collector.get_line_data()))
+ self.data.add_arc_data(abs_file_dict(self.collector.get_arc_data()))
+ self.data.add_plugin_data(abs_file_dict(self.collector.get_plugin_data()))
self.collector.reset()
# If there are still entries in the source_pkgs list, then we never
diff --git a/coverage/data.py b/coverage/data.py
index 8a699b5..22b711d 100644
--- a/coverage/data.py
+++ b/coverage/data.py
@@ -244,6 +244,10 @@ class CoverageData(object):
self.arcs.setdefault(filename, {}).update(arcs)
def add_plugin_data(self, plugin_data):
+ """Add per-file plugin information.
+
+ `plugin_data` is { filename: plugin_name, ... }
+ """
self.plugins.update(plugin_data)
def touch_file(self, filename):
diff --git a/tests/plugin2.py b/tests/plugin2.py
index 658ee22..70d2524 100644
--- a/tests/plugin2.py
+++ b/tests/plugin2.py
@@ -25,7 +25,8 @@ class RenderFileTracer(coverage.plugin.FileTracer):
def dynamic_source_filename(self, filename, frame):
if frame.f_code.co_name != "render":
return None
- return os.path.abspath(frame.f_locals['filename'])
+ source_filename = os.path.abspath(frame.f_locals['filename'])
+ return source_filename
def line_number_range(self, frame):
lineno = frame.f_locals['linenum']