當前位置: 首頁>>代碼示例>>Python>>正文


Python PluginManager.getplugins方法代碼示例

本文整理匯總了Python中_pytest.core.PluginManager.getplugins方法的典型用法代碼示例。如果您正苦於以下問題:Python PluginManager.getplugins方法的具體用法?Python PluginManager.getplugins怎麽用?Python PluginManager.getplugins使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在_pytest.core.PluginManager的用法示例。


在下文中一共展示了PluginManager.getplugins方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_plugin_prevent_register

# 需要導入模塊: from _pytest.core import PluginManager [as 別名]
# 或者: from _pytest.core.PluginManager import getplugins [as 別名]
 def test_plugin_prevent_register(self):
     pluginmanager = PluginManager()
     pluginmanager.consider_preparse(["xyz", "-p", "no:abc"])
     l1 = pluginmanager.getplugins()
     pluginmanager.register(42, name="abc")
     l2 = pluginmanager.getplugins()
     assert len(l2) == len(l1)
開發者ID:ProProgrammer,項目名稱:pytest,代碼行數:9,代碼來源:test_core.py

示例2: test_plugin_prevent_register_unregistered_alredy_registered

# 需要導入模塊: from _pytest.core import PluginManager [as 別名]
# 或者: from _pytest.core.PluginManager import getplugins [as 別名]
 def test_plugin_prevent_register_unregistered_alredy_registered(self):
     pluginmanager = PluginManager()
     pluginmanager.register(42, name="abc")
     l1 = pluginmanager.getplugins()
     assert 42 in l1
     pluginmanager.consider_preparse(["xyz", "-p", "no:abc"])
     l2 = pluginmanager.getplugins()
     assert 42 not in l2
開發者ID:ProProgrammer,項目名稱:pytest,代碼行數:10,代碼來源:test_core.py

示例3: test_pm_ordering

# 需要導入模塊: from _pytest.core import PluginManager [as 別名]
# 或者: from _pytest.core.PluginManager import getplugins [as 別名]
 def test_pm_ordering(self):
     pp = PluginManager()
     class A: pass
     a1, a2 = A(), A()
     pp.register(a1)
     pp.register(a2, "hello")
     l = pp.getplugins()
     assert l.index(a1) < l.index(a2)
     a3 = A()
     pp.register(a3, prepend=True)
     l = pp.getplugins()
     assert l.index(a3) == 0
開發者ID:ProProgrammer,項目名稱:pytest,代碼行數:14,代碼來源:test_core.py

示例4: test_consider_env_plugin_instantiation

# 需要導入模塊: from _pytest.core import PluginManager [as 別名]
# 或者: from _pytest.core.PluginManager import getplugins [as 別名]
 def test_consider_env_plugin_instantiation(self, testdir, monkeypatch):
     pluginmanager = PluginManager()
     testdir.syspathinsert()
     testdir.makepyfile(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('xy123')
     pluginmanager.consider_env()
     l3 = len(pluginmanager.getplugins())
     assert l2 == l3
開發者ID:ProProgrammer,項目名稱:pytest,代碼行數:15,代碼來源:test_core.py

示例5: test_register_imported_modules

# 需要導入模塊: from _pytest.core import PluginManager [as 別名]
# 或者: from _pytest.core.PluginManager import getplugins [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

示例6: test_register

# 需要導入模塊: from _pytest.core import PluginManager [as 別名]
# 或者: from _pytest.core.PluginManager import getplugins [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

示例7: test_import_plugin_importname

# 需要導入模塊: from _pytest.core import PluginManager [as 別名]
# 或者: from _pytest.core.PluginManager import getplugins [as 別名]
    def test_import_plugin_importname(self, testdir):
        pluginmanager = PluginManager()
        pytest.raises(ImportError, 'pluginmanager.import_plugin("qweqwex.y")')
        pytest.raises(ImportError, 'pluginmanager.import_plugin("pytest_qweqwx.y")')

        reset = testdir.syspathinsert()
        pluginname = "pytest_hello"
        testdir.makepyfile(**{pluginname: ""})
        pluginmanager.import_plugin("pytest_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("pytest_hello")
        assert plugin2 is plugin1
開發者ID:ProProgrammer,項目名稱:pytest,代碼行數:19,代碼來源:test_core.py

示例8: test_pm

# 需要導入模塊: from _pytest.core import PluginManager [as 別名]
# 或者: from _pytest.core.PluginManager import getplugins [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


注:本文中的_pytest.core.PluginManager.getplugins方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。