當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。