本文整理汇总了Python中_pytest.core.PluginManager.consider_module方法的典型用法代码示例。如果您正苦于以下问题:Python PluginManager.consider_module方法的具体用法?Python PluginManager.consider_module怎么用?Python PluginManager.consider_module使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类_pytest.core.PluginManager
的用法示例。
在下文中一共展示了PluginManager.consider_module方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_consider_module
# 需要导入模块: from _pytest.core import PluginManager [as 别名]
# 或者: from _pytest.core.PluginManager import consider_module [as 别名]
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"
示例2: test_consider_module_import_module
# 需要导入模块: from _pytest.core import PluginManager [as 别名]
# 或者: from _pytest.core.PluginManager import consider_module [as 别名]
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