Exemple #1
0
    def test_import_plugin_importname(self, testdir):
        pluginmanager = PluginManager()
        py.test.raises(ImportError, 'pluginmanager.import_plugin("x.y")')
        py.test.raises(ImportError, 'pluginmanager.import_plugin("pytest_x.y")')

        reset = testdir.syspathinsert()
        pluginname = "pytest_hello"
        testdir.makepyfile(**{pluginname: ""})
        pluginmanager.import_plugin("hello")
        len1 = len(pluginmanager.getplugins())
        pluginmanager.import_plugin("pytest_hello")
        len2 = len(pluginmanager.getplugins())
        assert len1 == len2
        plugin1 = pluginmanager.getplugin("pytest_hello")
        assert plugin1.__name__.endswith('pytest_hello')
        plugin2 = pluginmanager.getplugin("hello")
        assert plugin2 is plugin1
    def test_import_plugin_importname(self, testdir):
        pluginmanager = PluginManager()
        py.test.raises(ImportError, 'pluginmanager.import_plugin("x.y")')
        py.test.raises(ImportError,
                       'pluginmanager.import_plugin("pytest_x.y")')

        reset = testdir.syspathinsert()
        pluginname = "pytest_hello"
        testdir.makepyfile(**{pluginname: ""})
        pluginmanager.import_plugin("hello")
        len1 = len(pluginmanager.getplugins())
        pluginmanager.import_plugin("pytest_hello")
        len2 = len(pluginmanager.getplugins())
        assert len1 == len2
        plugin1 = pluginmanager.getplugin("pytest_hello")
        assert plugin1.__name__.endswith('pytest_hello')
        plugin2 = pluginmanager.getplugin("hello")
        assert plugin2 is plugin1
Exemple #3
0
 def test_consider_module(self, testdir):
     pluginmanager = PluginManager()
     testdir.syspathinsert()
     testdir.makepyfile(pytest_plug1="#")
     testdir.makepyfile(pytest_plug2="#")
     mod = py.std.new.module("temp")
     mod.pytest_plugins = ["pytest_plug1", "pytest_plug2"]
     pluginmanager.consider_module(mod)
     assert pluginmanager.getplugin("plug1").__name__ == "pytest_plug1"
     assert pluginmanager.getplugin("plug2").__name__ == "pytest_plug2"
 def test_consider_module(self, testdir):
     pluginmanager = PluginManager()
     testdir.syspathinsert()
     testdir.makepyfile(pytest_plug1="#")
     testdir.makepyfile(pytest_plug2="#")
     mod = py.std.new.module("temp")
     mod.pytest_plugins = ["pytest_plug1", "pytest_plug2"]
     pluginmanager.consider_module(mod)
     assert pluginmanager.getplugin("plug1").__name__ == "pytest_plug1"
     assert pluginmanager.getplugin("plug2").__name__ == "pytest_plug2"
Exemple #5
0
 def test_consider_env_plugin_instantiation(self, testdir, monkeypatch):
     pluginmanager = PluginManager()
     testdir.syspathinsert()
     testdir.makepyfile(pytest_xy123="#")
     monkeypatch.setitem(os.environ, 'PYTEST_PLUGINS', 'xy123')
     l1 = len(pluginmanager.getplugins())
     pluginmanager.consider_env()
     l2 = len(pluginmanager.getplugins())
     assert l2 == l1 + 1 
     assert pluginmanager.getplugin('pytest_xy123') 
     pluginmanager.consider_env()
     l3 = len(pluginmanager.getplugins())
     assert l2 == l3
 def test_consider_env_plugin_instantiation(self, testdir, monkeypatch):
     pluginmanager = PluginManager()
     testdir.syspathinsert()
     testdir.makepyfile(pytest_xy123="#")
     monkeypatch.setitem(os.environ, 'PYTEST_PLUGINS', 'xy123')
     l1 = len(pluginmanager.getplugins())
     pluginmanager.consider_env()
     l2 = len(pluginmanager.getplugins())
     assert l2 == l1 + 1
     assert pluginmanager.getplugin('pytest_xy123')
     pluginmanager.consider_env()
     l3 = len(pluginmanager.getplugins())
     assert l2 == l3