don't consider setuptools plugins if it is not installed.

--HG--
branch : trunk
This commit is contained in:
holger krekel 2009-11-24 10:49:04 +01:00
parent 79a9a99d1e
commit 9652be0ac1
2 changed files with 11 additions and 1 deletions

View File

@ -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

View File

@ -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("""