本文整理匯總了Python中_pytest.core.PluginManager.listattr方法的典型用法代碼示例。如果您正苦於以下問題:Python PluginManager.listattr方法的具體用法?Python PluginManager.listattr怎麽用?Python PluginManager.listattr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類_pytest.core.PluginManager
的用法示例。
在下文中一共展示了PluginManager.listattr方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_listattr
# 需要導入模塊: from _pytest.core import PluginManager [as 別名]
# 或者: from _pytest.core.PluginManager import listattr [as 別名]
def test_listattr(self):
pluginmanager = PluginManager()
class My2:
x = 42
pluginmanager.register(My2())
assert not pluginmanager.listattr("hello")
assert pluginmanager.listattr("x") == [42]
示例2: test_listattr_tryfirst
# 需要導入模塊: from _pytest.core import PluginManager [as 別名]
# 或者: from _pytest.core.PluginManager import listattr [as 別名]
def test_listattr_tryfirst(self):
class P1:
@pytest.mark.tryfirst
def m(self):
return 17
class P2:
def m(self):
return 23
class P3:
def m(self):
return 19
pluginmanager = PluginManager()
p1 = P1()
p2 = P2()
p3 = P3()
pluginmanager.register(p1)
pluginmanager.register(p2)
pluginmanager.register(p3)
methods = pluginmanager.listattr('m')
assert methods == [p2.m, p3.m, p1.m]
# listattr keeps a cache and deleting
# a function attribute requires clearing it
pluginmanager._listattrcache.clear()
del P1.m.__dict__['tryfirst']
pytest.mark.trylast(getattr(P2.m, 'im_func', P2.m))
methods = pluginmanager.listattr('m')
assert methods == [p2.m, p1.m, p3.m]