Exemple #1
0
 def test_consider_module(self, testdir):
     pluginmanager = PluginManager()
     testdir.syspathinsert()
     testdir.makepyfile(pytest_p1="#")
     testdir.makepyfile(pytest_p2="#")
     mod = py.std.types.ModuleType("temp")
     mod.pytest_plugins = ["pytest_p1", "pytest_p2"]
     pluginmanager.consider_module(mod)
     assert pluginmanager.getplugin("pytest_p1").__name__ == "pytest_p1"
     assert pluginmanager.getplugin("pytest_p2").__name__ == "pytest_p2"
Exemple #2
0
 def test_consider_module(self, testdir):
     pluginmanager = PluginManager()
     testdir.syspathinsert()
     testdir.makepyfile(pytest_p1="#")
     testdir.makepyfile(pytest_p2="#")
     mod = py.std.types.ModuleType("temp")
     mod.pytest_plugins = ["pytest_p1", "pytest_p2"]
     pluginmanager.consider_module(mod)
     assert pluginmanager.getplugin("pytest_p1").__name__ == "pytest_p1"
     assert pluginmanager.getplugin("pytest_p2").__name__ == "pytest_p2"
Exemple #3
0
    def test_consider_module_import_module(self, testdir):
        mod = py.std.types.ModuleType("x")
        mod.pytest_plugins = "pytest_a"
        aplugin = testdir.makepyfile(pytest_a="#")
        pluginmanager = PluginManager()
        reprec = testdir.getreportrecorder(pluginmanager)
        #syspath.prepend(aplugin.dirpath())
        py.std.sys.path.insert(0, str(aplugin.dirpath()))
        pluginmanager.consider_module(mod)
        call = reprec.getcall(pluginmanager.hook.pytest_plugin_registered.name)
        assert call.plugin.__name__ == "pytest_a"

        # check that it is not registered twice
        pluginmanager.consider_module(mod)
        l = reprec.getcalls("pytest_plugin_registered")
        assert len(l) == 1
Exemple #4
0
    def test_consider_module_import_module(self, testdir):
        mod = py.std.types.ModuleType("x")
        mod.pytest_plugins = "pytest_a"
        aplugin = testdir.makepyfile(pytest_a="#")
        pluginmanager = PluginManager()
        reprec = testdir.getreportrecorder(pluginmanager)
        #syspath.prepend(aplugin.dirpath())
        py.std.sys.path.insert(0, str(aplugin.dirpath()))
        pluginmanager.consider_module(mod)
        call = reprec.getcall(pluginmanager.hook.pytest_plugin_registered.name)
        assert call.plugin.__name__ == "pytest_a"

        # check that it is not registered twice
        pluginmanager.consider_module(mod)
        l = reprec.getcalls("pytest_plugin_registered")
        assert len(l) == 1