From e103932aad78c3072ee3b81d5e4f7c801ef1d23a Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sun, 9 Aug 2015 19:30:49 -0300 Subject: [PATCH] Reintroduce hasplugin to PytestPluginManager Fix #932 --- _pytest/config.py | 4 ++++ testing/acceptance_test.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/_pytest/config.py b/_pytest/config.py index 85c892a51..e2afaa976 100644 --- a/_pytest/config.py +++ b/_pytest/config.py @@ -211,6 +211,10 @@ class PytestPluginManager(PluginManager): # support deprecated naming because plugins (xdist e.g.) use it return self.get_plugin(name) + def hasplugin(self, name): + """Return True if the plugin with the given name is registered.""" + return bool(self.get_plugin(name)) + def pytest_configure(self, config): # XXX now that the pluginmanager exposes hookimpl(tryfirst...) # we should remove tryfirst/trylast as markers diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index d845fd46a..2e87ac466 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -586,6 +586,11 @@ class TestInvocationVariants: assert type(_pytest.config.get_plugin_manager()) is _pytest.config.PytestPluginManager + def test_has_plugin(self, request): + """Test hasplugin function of the plugin manager (#932).""" + assert request.config.pluginmanager.hasplugin('python') + + class TestDurations: source = """ import time