本文整理匯總了Python中lancelot.Spec.verify_fn方法的典型用法代碼示例。如果您正苦於以下問題:Python Spec.verify_fn方法的具體用法?Python Spec.verify_fn怎麽用?Python Spec.verify_fn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類lancelot.Spec
的用法示例。
在下文中一共展示了Spec.verify_fn方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: should_execute_fn
# 需要導入模塊: from lancelot import Spec [as 別名]
# 或者: from lancelot.Spec import verify_fn [as 別名]
def should_execute_fn(self):
''' verify_fn() should execute the fn '''
a_list = []
lambda_list_append = lambda: a_list.append(len(a_list))
spec = Spec(AllVerifiable, given=silent_listener)
spec.when(spec.verify_fn(verifiable_fn=string_abc))
spec.then(a_list.__len__).should_be(0)
spec.when(spec.verify_fn(verifiable_fn=lambda_list_append))
spec.then(a_list.__len__).should_be(1)
示例2: should_handle_exceptions
# 需要導入模塊: from lancelot import Spec [as 別名]
# 或者: from lancelot.Spec import verify_fn [as 別名]
def should_handle_exceptions(self):
''' verify_fn() should handle exceptions gracefully '''
spec = Spec(AllVerifiable, given=silent_listener)
spec.verify_fn(raise_index_error).should_not_raise(Exception)
示例3: should_return_0_or_1
# 需要導入模塊: from lancelot import Spec [as 別名]
# 或者: from lancelot.Spec import verify_fn [as 別名]
def should_return_0_or_1(self):
''' verify_fn() should return 1 for success, 0 for unmet
specification'''
spec = Spec(AllVerifiable, given=silent_listener)
spec.verify_fn(verifiable_fn=raise_index_error).should_be(0)
spec.verify_fn(verifiable_fn=dont_raise_index_error).should_be(1)