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


Python Spec.verify方法代码示例

本文整理汇总了Python中lancelot.Spec.verify方法的典型用法代码示例。如果您正苦于以下问题:Python Spec.verify方法的具体用法?Python Spec.verify怎么用?Python Spec.verify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lancelot.Spec的用法示例。


在下文中一共展示了Spec.verify方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: should_check_message

# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import verify [as 别名]
 def should_check_message(self):
     ''' Raise should verify exception type & message vs specified ''' 
     spec = Spec(Raise(IndexError('with message')))
     spec.verify(raise_index_error).should_not_raise(UnmetSpecification)
     
     spec = Spec(Raise(IndexError('with different message')))
     spec.verify(raise_index_error).should_raise(UnmetSpecification)
开发者ID:gbremer,项目名称:lancelot,代码行数:9,代码来源:constraint_spec.py

示例2: verify_should_invoke_callable

# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import verify [as 别名]
 def verify_should_invoke_callable(self):
     ''' verify should invoke callable and compare result '''
     a_list = []
     with_callable = lambda: a_list.append(True)
     spec = Spec(Constraint())
     spec.verify(with_callable).should_raise(UnmetSpecification)
     spec.then(a_list.__len__).should_be(1)
开发者ID:gbremer,项目名称:lancelot,代码行数:9,代码来源:constraint_spec.py

示例3: should_trap_incorrect_return

# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import verify [as 别名]
 def should_trap_incorrect_return(self):
     ''' Specified and_result="bar" but was "baz": UnmetSpecification.
     Note: and_result refers to the value returned from the callable  
     invoked in verify(), not the return value from the mock. See
     the Hungarian gentleman in the examples for a clearer picture... ''' 
     mock_spec = MockSpec()
     spec = Spec(CollaborateWith(mock_spec.foo().will_return('baz'), 
                                 and_result='bar'))
     spec.verify(lambda: mock_spec.foo()).should_raise(UnmetSpecification)
开发者ID:gbremer,项目名称:lancelot,代码行数:11,代码来源:constraint_spec.py

示例4: should_trap_incorrect_args

# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import verify [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

示例5: should_check_unverified_collaborations

# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import verify [as 别名]
 def should_check_unverified_collaborations(self):
     ''' check for unverified collaborations after start_collaborating '''
     spec = Spec(MockSpec())
     spec.when(spec.foo(), spec.start_collaborating())
     spec.then(spec.verify())
     msg = 'should be collaborating with unnamed_mock.foo()'
     spec.should_raise(UnmetSpecification(msg))
     
     spec = Spec(MockSpec())
     spec.when(spec.foo(), spec.start_collaborating(), spec.foo())
     spec.then(spec.verify())
     spec.should_not_raise(UnmetSpecification)
开发者ID:gbremer,项目名称:lancelot,代码行数:14,代码来源:mocking_spec.py

示例6: should_have_meaningful_msg

# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import verify [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

示例7: all_verif_failfast_behaviour

# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import verify [as 别名]
def  all_verif_failfast_behaviour():
    ''' verify(fail_fast=True) should stop after the first unmet specification
    or unexpected exception'''    
    spec = Spec(AllVerifiable, given=silent_listener)
    spec.when(spec.include(raise_index_error), 
              spec.include(dont_raise_index_error))
    spec.then(spec.verify(fail_fast=True))
    spec.should_be({'total':2, 'verified':0, 'unverified':2, 'fail_fast':True})

    spec = Spec(AllVerifiable, given=silent_listener)
    spec.when(spec.include(unmet_specification), 
              spec.include(dont_raise_index_error))
    spec.then(spec.verify(fail_fast=True))
    spec.should_be({'total':2, 'verified':0, 'unverified':2, 'fail_fast':True})
开发者ID:gbremer,项目名称:lancelot,代码行数:16,代码来源:verification_spec.py

示例8: should_return_all_results

# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import verify [as 别名]
    def should_return_all_results(self): 
        ''' verify() should return the result of all attempted / successful 
        verifications '''
        spec = Spec(AllVerifiable, given=silent_listener)
        spec.verify().should_be({'total':0, 'verified':0, 'unverified':0})

        spec = Spec(AllVerifiable, given=silent_listener)
        spec.when(spec.include(number_one))
        spec.then(spec.verify())
        spec.should_be({'total':1, 'verified':1, 'unverified':0})
    
        spec.when(spec.include(raise_index_error))
        spec.then(spec.verify())
        spec.should_be({'total':2, 'verified':1, 'unverified':1})
开发者ID:gbremer,项目名称:lancelot,代码行数:16,代码来源:verification_spec.py

示例9: should_verify_each_item

# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import verify [as 别名]
 def should_verify_each_item(self):
     ''' verify() should execute each included item '''
     a_list = []
     lambda_list_append1 = lambda: a_list.append(0)
     lambda_list_append2 = lambda: a_list.extend((1, 2)) 
     
     spec = Spec(AllVerifiable, given=silent_listener)
     spec.when(spec.include(lambda_list_append1), 
               spec.include(lambda_list_append2), 
               spec.verify())
     spec.then(a_list.__len__).should_be(3)
开发者ID:gbremer,项目名称:lancelot,代码行数:13,代码来源:verification_spec.py

示例10: grouped_methods_should_verify

# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import verify [as 别名]
 def grouped_methods_should_verify(self):
     ''' grouping() methods should allow them to be executed & verified '''
     all_verifiable = silent_listener()
     def add_related_verifiables():
         grouping(RelatedVerifiables, all_verifiable)
         verifiable(RelatedVerifiables.verifiable1, all_verifiable)
         verifiable(RelatedVerifiables.verifiable2, all_verifiable)
     all_verifiable.add_related_verifiables = add_related_verifiables
        
     spec = Spec(all_verifiable)
     spec.when(spec.add_related_verifiables())
     spec.then(spec.total()).should_be(2)
     spec.then(spec.verify())
     spec.should_be({'total':2, 'verified':2, 'unverified':0})
开发者ID:gbremer,项目名称:lancelot,代码行数:16,代码来源:verification_spec.py

示例11: not_behaviour

# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import verify [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

示例12: notification_behaviour

# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import verify [as 别名]
def notification_behaviour(): 
    ''' listener should receive notifications AllVerifiable.verify() '''
    listener = MockSpec()
    all_verifiable_with_mock_listener = AllVerifiable(listener)
    results = {'total': 3, 'verified': 1, 'unverified': 2}
    
    spec = Spec(all_verifiable_with_mock_listener)
    spec.when(spec.include(string_abc), 
              spec.include(raise_index_error),
              spec.include(unmet_specification)) 
    spec.then(spec.verify())
    spec.should_collaborate_with(
        listener.all_verifiable_starting(all_verifiable_with_mock_listener),
        listener.verification_started(string_abc),
        listener.specification_met(string_abc),
        listener.verification_started(raise_index_error),
        listener.unexpected_exception(raise_index_error, Type(IndexError)),
        listener.verification_started(unmet_specification),
        listener.specification_unmet(unmet_specification, 
                                     Type(UnmetSpecification)),
        listener.all_verifiable_ending(all_verifiable_with_mock_listener, 
                                       results),
        and_result = results)
开发者ID:gbremer,项目名称:lancelot,代码行数:25,代码来源:verification_spec.py

示例13: should_check_type

# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import verify [as 别名]
 def should_check_type(self):
     ''' Raise should check that exception is raised '''
     spec = Spec(Raise(IndexError))
     spec.verify(raise_index_error).should_not_raise(UnmetSpecification)
     spec.verify(dont_raise_index_error).should_raise(UnmetSpecification)
开发者ID:gbremer,项目名称:lancelot,代码行数:7,代码来源:constraint_spec.py

示例14: verify_should_use_comparator

# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import verify [as 别名]
 def verify_should_use_comparator(self):
     ''' verify should delegate to comparator.compares_to ''' 
     comparator = MockSpec()
     spec = Spec(Constraint(comparator))
     comparator_compares_to = comparator.compares_to(1).will_return(True)
     spec.verify(lambda: 1).should_collaborate_with(comparator_compares_to)
开发者ID:gbremer,项目名称:lancelot,代码行数:8,代码来源:constraint_spec.py

示例15: correct_call_should_be_ok

# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import verify [as 别名]
 def correct_call_should_be_ok(self):
     ''' Specified foo() and foo() called: met specification '''
     mock_spec = MockSpec()
     spec = Spec(CollaborateWith(mock_spec.foo()))
     spec.verify(lambda: mock_spec.foo())
     spec.should_not_raise(UnmetSpecification)
开发者ID:gbremer,项目名称:lancelot,代码行数:8,代码来源:constraint_spec.py


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