summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2018-02-10 12:39:36 -0500
committerNed Batchelder <ned@nedbatchelder.com>2018-02-10 12:39:36 -0500
commit50352aa21ae4ad3943c7402cdc129ee862403dc1 (patch)
treec564b6a89da750f1c3468bb2a8ec0c1f32bb2159
parentbcf1e4a137561104fc454aa57f478cd6d50c6ca8 (diff)
downloadpython-coveragepy-50352aa21ae4ad3943c7402cdc129ee862403dc1.tar.gz
Configurer plugins should be reported by --debug=sys
-rw-r--r--CHANGES.rst4
-rw-r--r--coverage/control.py18
-rw-r--r--tests/test_plugins.py12
3 files changed, 21 insertions, 13 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index ad401eb..e18f9dc 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -20,7 +20,7 @@ Unreleased
----------
- Now that 4.5 properly separated the ``[run] omit`` and ``[report] omit``
- settings, and old bug has become apparent. If you specified a package name
+ settings, an old bug has become apparent. If you specified a package name
for ``[run] source``, then omit patterns weren't matched inside that package.
This bug (`issue 638`_) is now fixed.
@@ -28,6 +28,8 @@ Unreleased
docstring would crash coverage.py with an IndexError (`issue 640`_). This is
now fixed.
+- Configurer plugins are now being reported in the output of ``--debug=sys``.
+
.. _issue 638: https://bitbucket.org/ned/coveragepy/issues/638/run-omit-is-ignored-since-45
.. _issue 640: https://bitbucket.org/ned/coveragepy/issues/640/indexerror-reporting-on-an-empty-decorated
diff --git a/coverage/control.py b/coverage/control.py
index 71692de..b82c804 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -1152,12 +1152,15 @@ class Coverage(object):
self._init()
- ft_plugins = []
- for ft in self.plugins.file_tracers:
- ft_name = ft._coverage_plugin_name
- if not ft._coverage_enabled:
- ft_name += " (disabled)"
- ft_plugins.append(ft_name)
+ def plugin_info(plugins):
+ """Make an entry for the sys_info from a list of plug-ins."""
+ entries = []
+ for plugin in plugins:
+ entry = plugin._coverage_plugin_name
+ if not plugin._coverage_enabled:
+ entry += " (disabled)"
+ entries.append(entry)
+ return entries
info = [
('version', covmod.__version__),
@@ -1165,7 +1168,8 @@ class Coverage(object):
('cover_paths', self.cover_paths),
('pylib_paths', self.pylib_paths),
('tracer', self.collector.tracer_name()),
- ('plugins.file_tracers', ft_plugins),
+ ('plugins.file_tracers', plugin_info(self.plugins.file_tracers)),
+ ('plugins.configurers', plugin_info(self.plugins.configurers)),
('config_files', self.config.attempted_config_files),
('configs_read', self.config.config_files),
('data_path', self.data_files.filename),
diff --git a/tests/test_plugins.py b/tests/test_plugins.py
index 2e8d52f..0775276 100644
--- a/tests/test_plugins.py
+++ b/tests/test_plugins.py
@@ -183,7 +183,7 @@ class PluginTest(CoverageTest):
return [("hello", "world")]
def coverage_init(reg, options):
- reg.add_noop(Plugin())
+ reg.add_file_tracer(Plugin())
""")
debug_out = StringIO()
cov = coverage.Coverage(debug=["sys"])
@@ -191,10 +191,11 @@ class PluginTest(CoverageTest):
cov.set_option("run:plugins", ["plugin_sys_info"])
cov.load()
- out_lines = debug_out.getvalue().splitlines()
+ out_lines = [line.strip() for line in debug_out.getvalue().splitlines()]
+ self.assertIn('plugins.file_tracers: plugin_sys_info.Plugin', out_lines)
expected_end = [
"-- sys: plugin_sys_info.Plugin -------------------------------",
- " hello: world",
+ "hello: world",
"-- end -------------------------------------------------------",
]
self.assertEqual(expected_end, out_lines[-len(expected_end):])
@@ -207,7 +208,7 @@ class PluginTest(CoverageTest):
pass
def coverage_init(reg, options):
- reg.add_noop(Plugin())
+ reg.add_configurer(Plugin())
""")
debug_out = StringIO()
cov = coverage.Coverage(debug=["sys"])
@@ -215,7 +216,8 @@ class PluginTest(CoverageTest):
cov.set_option("run:plugins", ["plugin_no_sys_info"])
cov.load()
- out_lines = debug_out.getvalue().splitlines()
+ out_lines = [line.strip() for line in debug_out.getvalue().splitlines()]
+ self.assertIn('plugins.configurers: plugin_no_sys_info.Plugin', out_lines)
expected_end = [
"-- sys: plugin_no_sys_info.Plugin ----------------------------",
"-- end -------------------------------------------------------",