本文整理匯總了Python中testtools.matchers方法的典型用法代碼示例。如果您正苦於以下問題:Python testtools.matchers方法的具體用法?Python testtools.matchers怎麽用?Python testtools.matchers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類testtools
的用法示例。
在下文中一共展示了testtools.matchers方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: checkDatabaseUse
# 需要導入模塊: import testtools [as 別名]
# 或者: from testtools import matchers [as 別名]
def checkDatabaseUse(self):
"""Enforce `database_use_permitted`."""
if self.database_use_possible and not self.database_use_permitted:
from django.db import connection
self.expectThat(
connection.connection,
testtools.matchers.Is(None),
"Test policy forbids use of the database.",
)
connection.close()
示例2: assertAttributes
# 需要導入模塊: import testtools [as 別名]
# 或者: from testtools import matchers [as 別名]
def assertAttributes(self, tested_object, attributes):
"""Check multiple attributes of `tested_object` against a dict.
:param tested_object: Any object whose attributes should be checked.
:param attributes: A dict of attributes to test, and their expected
values. Only these attributes will be checked.
"""
matcher = testtools.matchers.MatchesStructure.byEquality(**attributes)
self.assertThat(tested_object, matcher)