本文整理汇总了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)