当前位置: 首页>>代码示例>>Python>>正文


Python PluginManager.isregistered方法代码示例

本文整理汇总了Python中_pytest.core.PluginManager.isregistered方法的典型用法代码示例。如果您正苦于以下问题:Python PluginManager.isregistered方法的具体用法?Python PluginManager.isregistered怎么用?Python PluginManager.isregistered使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在_pytest.core.PluginManager的用法示例。


在下文中一共展示了PluginManager.isregistered方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_register

# 需要导入模块: from _pytest.core import PluginManager [as 别名]
# 或者: from _pytest.core.PluginManager import isregistered [as 别名]
    def test_register(self):
        pm = PluginManager(load=False)
        class MyPlugin:
            pass
        my = MyPlugin()
        pm.register(my)
        assert pm.getplugins()
        my2 = MyPlugin()
        pm.register(my2)
        assert pm.getplugins()[1:] == [my, my2]

        assert pm.isregistered(my)
        assert pm.isregistered(my2)
        pm.unregister(my)
        assert not pm.isregistered(my)
        assert pm.getplugins()[1:] == [my2]
开发者ID:ProProgrammer,项目名称:pytest,代码行数:18,代码来源:test_core.py

示例2: test_canonical_import

# 需要导入模块: from _pytest.core import PluginManager [as 别名]
# 或者: from _pytest.core.PluginManager import isregistered [as 别名]
 def test_canonical_import(self, monkeypatch):
     mod = py.std.types.ModuleType("pytest_xyz")
     monkeypatch.setitem(py.std.sys.modules, 'pytest_xyz', mod)
     pp = PluginManager()
     pp.import_plugin('pytest_xyz')
     assert pp.getplugin('pytest_xyz') == mod
     assert pp.isregistered(mod)
开发者ID:ProProgrammer,项目名称:pytest,代码行数:9,代码来源:test_core.py

示例3: test_pm

# 需要导入模块: from _pytest.core import PluginManager [as 别名]
# 或者: from _pytest.core.PluginManager import isregistered [as 别名]
 def test_pm(self):
     pp = PluginManager()
     class A: pass
     a1, a2 = A(), A()
     pp.register(a1)
     assert pp.isregistered(a1)
     pp.register(a2, "hello")
     assert pp.isregistered(a2)
     l = pp.getplugins()
     assert a1 in l
     assert a2 in l
     assert pp.getplugin('hello') == a2
     pp.unregister(a1)
     assert not pp.isregistered(a1)
     pp.unregister(name="hello")
     assert not pp.isregistered(a2)
开发者ID:ProProgrammer,项目名称:pytest,代码行数:18,代码来源:test_core.py

示例4: test_register_imported_modules

# 需要导入模块: from _pytest.core import PluginManager [as 别名]
# 或者: from _pytest.core.PluginManager import isregistered [as 别名]
 def test_register_imported_modules(self):
     pp = PluginManager()
     mod = py.std.types.ModuleType("x.y.pytest_hello")
     pp.register(mod)
     assert pp.isregistered(mod)
     l = pp.getplugins()
     assert mod in l
     pytest.raises(AssertionError, "pp.register(mod)")
     mod2 = py.std.types.ModuleType("pytest_hello")
     #pp.register(mod2) # double pm
     pytest.raises(AssertionError, "pp.register(mod)")
     #assert not pp.isregistered(mod2)
     assert pp.getplugins() == l
开发者ID:ProProgrammer,项目名称:pytest,代码行数:15,代码来源:test_core.py


注:本文中的_pytest.core.PluginManager.isregistered方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。