streamlined plugin loading: order is now setuptools, ENV, commandline
and setuptools entry point names are turned to canonical namees ("pytest_*")
--HG--
branch : trunk
This commit is contained in:
@@ -237,3 +237,24 @@ def test_ensuretemp(recwarn):
|
||||
d2 = py.test.ensuretemp('hello')
|
||||
assert d1 == d2
|
||||
assert d1.check(dir=1)
|
||||
|
||||
def test_preparse_ordering(testdir, monkeypatch):
|
||||
pkg_resources = py.test.importorskip("pkg_resources")
|
||||
def my_iter(name):
|
||||
assert name == "pytest11"
|
||||
class EntryPoint:
|
||||
name = "mytestplugin"
|
||||
def load(self):
|
||||
class PseudoPlugin:
|
||||
x = 42
|
||||
return PseudoPlugin()
|
||||
return iter([EntryPoint()])
|
||||
monkeypatch.setattr(pkg_resources, 'iter_entry_points', my_iter)
|
||||
testdir.makeconftest("""
|
||||
pytest_plugins = "mytestplugin",
|
||||
""")
|
||||
monkeypatch.setenv("PYTEST_PLUGINS", "mytestplugin")
|
||||
config = testdir.parseconfig()
|
||||
plugin = config.pluginmanager.getplugin("mytestplugin")
|
||||
assert plugin.x == 42
|
||||
|
||||
|
||||
@@ -61,6 +61,8 @@ class TestBootstrapping:
|
||||
pluginmanager.consider_setuptools_entrypoints()
|
||||
plugin = pluginmanager.getplugin("mytestplugin")
|
||||
assert plugin.x == 42
|
||||
plugin2 = pluginmanager.getplugin("pytest_mytestplugin")
|
||||
assert plugin2 == plugin
|
||||
|
||||
def test_consider_setuptools_not_installed(self, monkeypatch):
|
||||
monkeypatch.setitem(py.std.sys.modules, 'pkg_resources',
|
||||
|
||||
Reference in New Issue
Block a user