本文整理汇总了Python中lancelot.Spec.describe_constraint方法的典型用法代码示例。如果您正苦于以下问题:Python Spec.describe_constraint方法的具体用法?Python Spec.describe_constraint怎么用?Python Spec.describe_constraint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lancelot.Spec
的用法示例。
在下文中一共展示了Spec.describe_constraint方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: desc_should_use_comparator
# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import describe_constraint [as 别名]
def desc_should_use_comparator(self):
''' describe_constraint should delegate to comparator.description '''
comparator = MockSpec()
spec = Spec(Constraint(comparator))
comparator_description = comparator.description()
comparator_description.will_return('subtitled')
spec.describe_constraint()
spec.should_collaborate_with(comparator_description,
and_result='should be subtitled')
示例2: should_use_nothing_comparator
# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import describe_constraint [as 别名]
def should_use_nothing_comparator(self):
''' Constraint should use Nothing comparator by default'''
spec = Spec(Constraint())
spec.describe_constraint().should_be('should be nothing')
spec.verify_value(1).should_be(False)
spec.verify_value(2).should_be(False)
spec.verify_value(None).should_be(False)
spec.verify_value(['majestic', 'moose']).should_be(False)
spec.verify_value({'gumby': 'brain surgeon'}).should_be(False)
示例3: should_trap_incorrect_args
# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import describe_constraint [as 别名]
def should_trap_incorrect_args(self):
''' Specified foo(2) & bar(), and foo(1) called: UnmetSpecification'''
mock_spec = MockSpec()
collaborations = (mock_spec.foo(2), mock_spec.bar())
descriptions = [collaboration.description()
for collaboration in collaborations]
spec = Spec(CollaborateWith(*collaborations))
spec.describe_constraint().should_be(','.join(descriptions))
spec.verify(lambda: mock_spec.foo(1)).should_raise(UnmetSpecification)
示例4: not_behaviour
# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import describe_constraint [as 别名]
def not_behaviour():
''' Not should raise exception iff underlying check succeeds '''
spec = Spec(Not(Constraint(EqualsEquals(2))))
spec.verify(number_one).should_not_raise(UnmetSpecification)
spec = Spec(Not(Constraint(EqualsEquals(1))))
msg = 'should not be == 1'
spec.describe_constraint().should_be(msg)
spec.verify(number_one).should_raise(UnmetSpecification(msg))
spec = Spec(Not(Not(Constraint(EqualsEquals(2)))))
msg = 'should be == 2'
spec.describe_constraint().should_be(msg)
spec.verify(number_one).should_raise(UnmetSpecification(msg))
示例5: should_have_meaningful_msg
# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import describe_constraint [as 别名]
def should_have_meaningful_msg(self):
''' Raise should produce meaningful UnmetSpecification messages'''
spec = Spec(Raise(IndexError))
msg = "should raise IndexError"
spec.describe_constraint().should_be(msg)
spec.verify(dont_raise_index_error)
spec.should_raise(UnmetSpecification(msg))
spec = Spec(Raise(IndexError('with some message')))
msg = "should raise IndexError('with some message',)"
spec.describe_constraint().should_be(msg)
unmet_msg = msg + ", not IndexError('with message',)"
unmet_specification = UnmetSpecification(unmet_msg)
spec.verify(raise_index_error).should_raise(unmet_specification)
示例6: should_trap_incorrect_call
# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import describe_constraint [as 别名]
def should_trap_incorrect_call(self):
''' Specified foo() but bar() called: UnmetSpecification '''
mock_spec = MockSpec()
spec = Spec(CollaborateWith(mock_spec.foo()))
spec.describe_constraint().should_be(mock_spec.foo().description())
spec.verify(lambda: mock_spec.bar()).should_raise(UnmetSpecification)