diff --git a/py/impl/test/pluginmanager.py b/py/impl/test/pluginmanager.py index 85060bef7..c093d9549 100644 --- a/py/impl/test/pluginmanager.py +++ b/py/impl/test/pluginmanager.py @@ -78,7 +78,10 @@ class PluginManager(object): self.import_plugin(spec) def consider_setuptools_entrypoints(self): - from pkg_resources import iter_entry_points + try: + from pkg_resources import iter_entry_points + except ImportError: + return # XXX issue a warning for ep in iter_entry_points('pytest11'): if ep.name in self._name2plugin: continue diff --git a/testing/pytest/test_pluginmanager.py b/testing/pytest/test_pluginmanager.py index 9050d8451..63905033c 100644 --- a/testing/pytest/test_pluginmanager.py +++ b/testing/pytest/test_pluginmanager.py @@ -60,6 +60,13 @@ class TestBootstrapping: plugin = pluginmanager.getplugin("mytestplugin") assert plugin.x == 42 + def test_consider_setuptools_not_installed(self, monkeypatch): + monkeypatch.setitem(py.std.sys.modules, 'pkg_resources', + py.std.types.ModuleType("pkg_resources")) + pluginmanager = PluginManager() + pluginmanager.consider_setuptools_entrypoints() + # ok, we did not explode + def test_pluginmanager_ENV_startup(self, testdir, monkeypatch): x500 = testdir.makepyfile(pytest_x500="#") p = testdir.makepyfile("""