From c283ccda4cdd2eea3a22a06619d0460cbc8440cb Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 20 Jul 2015 08:40:23 -0400 Subject: Be more strict when recording plugin names --- coverage/data.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'coverage/data.py') diff --git a/coverage/data.py b/coverage/data.py index e5c37cb7..b1fcd212 100644 --- a/coverage/data.py +++ b/coverage/data.py @@ -216,7 +216,20 @@ class CoverageData(object): `plugin_data` is { filename: plugin_name, ... } """ - self._plugins.update(plugin_data) + existing_files = self._arcs or self._lines + for filename, plugin_name in iitems(plugin_data): + if filename not in existing_files: + raise CoverageException( + "Can't add plugin data for unmeasured file '%s'" % (filename,) + ) + existing_plugin = self._plugins.get(filename) + if existing_plugin is not None and plugin_name != existing_plugin: + raise CoverageException( + "Conflicting plugin name for '%s': %r vs %r" % ( + filename, existing_plugin, plugin_name, + ) + ) + self._plugins[filename] = plugin_name def update(self, other_data, aliases=None): """Update this data with data from another `CoverageData`. -- cgit v1.2.1