当前位置: 首页>>代码示例>>Python>>正文


Python Spec.describe_constraint方法代码示例

本文整理汇总了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')
开发者ID:gbremer,项目名称:lancelot,代码行数:11,代码来源:constraint_spec.py

示例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)
开发者ID:gbremer,项目名称:lancelot,代码行数:11,代码来源:constraint_spec.py

示例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)
开发者ID:gbremer,项目名称:lancelot,代码行数:11,代码来源:constraint_spec.py

示例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))
开发者ID:gbremer,项目名称:lancelot,代码行数:16,代码来源:constraint_spec.py

示例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)
开发者ID:gbremer,项目名称:lancelot,代码行数:16,代码来源:constraint_spec.py

示例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)
开发者ID:gbremer,项目名称:lancelot,代码行数:8,代码来源:constraint_spec.py


注:本文中的lancelot.Spec.describe_constraint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。