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


Python Spec.then方法代码示例

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


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

示例1: verify_should_invoke_callable

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

示例2: should_increment

# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import then [as 别名]
 def should_increment(self):
     ''' total() should increment as verifiable_fn is included '''
     spec = Spec(AllVerifiable, given=silent_listener)
     spec.total().should_be(0)
     
     spec.when(spec.include(raise_index_error))
     spec.then(spec.total()).should_be(1)
     
     spec.when(spec.include(dont_raise_index_error))
     spec.then(spec.total()).should_be(2)
开发者ID:gbremer,项目名称:lancelot,代码行数:12,代码来源:verification_spec.py

示例3: should_execute_fn

# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import then [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)
开发者ID:gbremer,项目名称:lancelot,代码行数:12,代码来源:verification_spec.py

示例4: should_add_to_collation

# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import then [as 别名]
 def should_add_to_collation(self): 
     ''' verifiable should add fn to ALL_VERIFIABLE and return it '''
     all_verifiable = silent_listener()
 
     spec = Spec(verifiable)
     spec.verifiable(number_one, all_verifiable).should_be(number_one)
     
     num_verifiable_before = all_verifiable.total()
     spec.when(spec.verifiable(string_abc, all_verifiable))
     spec.then(all_verifiable.total).should_be(num_verifiable_before + 1)
开发者ID:gbremer,项目名称:lancelot,代码行数:12,代码来源:verification_spec.py

示例5: should_verify_each_item

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

示例6: should_check_unverified_collaborations

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

示例7: external_then_behaviour

# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import then [as 别名]
def external_then_behaviour(): 
    ''' Spec for then()... actions that call outside the spec itself.
    
    Note that the action on the spec is invoked in client code with parens():
        spec.then( * spec.__len__() * ).should_be(1)
        
    but the action outside the spec is NOT:
        spec.then( * 'they called him brian'.__len__ * ).should_be(21) 
    '''
    spec = Spec([])
    spec.when(spec.append('brian'))
    spec.then(spec.__len__()).should_be(1)
    spec.then('they called him brian'.__len__).should_be(21) 
开发者ID:gbremer,项目名称:lancelot,代码行数:15,代码来源:specification_spec.py

示例8: supply_different_values_each_time

# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import then [as 别名]
 def supply_different_values_each_time(self):
     ''' supplies(a,b,...) should return a,b,... on successive
     calls '''
     spec = Spec(MockResult(MockCall(MockSpec(), '')))
     spec.when(spec.times(3))
     spec.then(spec.supplies('x', 
                                       'y', 
                                       'z')).should_not_raise(ValueError)
     spec.then(spec.specified_times()).should_be(3)
     spec.then(spec.next()).should_be('x')
     spec.then(spec.next()).should_be('y')
     spec.then(spec.next()).should_be('z')
     spec.then(spec.next()).should_raise(UnmetSpecification)
开发者ID:gbremer,项目名称:lancelot,代码行数:15,代码来源:mocking_spec.py

示例9: grouped_methods_should_verify

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

示例10: should_return_all_results

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

示例11: all_verif_failfast_behaviour

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

示例12: supply_single_value_twice

# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import then [as 别名]
 def supply_single_value_twice(self):
     ''' combining supplies(a_value) & times(2) (in any order) 
     should return a_value, twice '''
     spec = Spec(MockResult(MockCall(None, '')))
     spec.when(spec.times(2), spec.supplies('f'))
     spec.then(spec.specified_times()).should_be(2)
     spec.then(spec.next()).should_be('f')
     spec.then(spec.next()).should_be('f')
 
     spec = Spec(MockResult(MockCall(None, '')))
     spec.when(spec.supplies('f'), spec.times(2))
     spec.then(spec.specified_times()).should_be(2)
     spec.then(spec.next()).should_be('f')
     spec.then(spec.next()).should_be('f')
开发者ID:gbremer,项目名称:lancelot,代码行数:16,代码来源:mocking_spec.py

示例13: defaults

# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import then [as 别名]
 def defaults(self):
     ''' By default should return None just once ''' 
     spec = Spec(MockResult(MockCall(MockSpec(), '')))
     spec.specified_times().should_be(1)
     spec.times_remaining().should_be(1)
     spec.then(spec.next()).should_be(None)
     spec.then(spec.times_remaining()).should_be(0)
     spec.then(spec.next()).should_raise(UnmetSpecification)
开发者ID:gbremer,项目名称:lancelot,代码行数:10,代码来源:mocking_spec.py

示例14: notification_behaviour

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

示例15: raise_exception

# 需要导入模块: from lancelot import Spec [as 别名]
# 或者: from lancelot.Spec import then [as 别名]
    def raise_exception(self):
        ''' raises(exception) should raise exceptions in the same
        fashion as will_suppply_values should return values '''
        spec = Spec(MockResult(MockCall(MockSpec(), '')))
        exception = ValueError('the number of the counting shall be three')
        spec.when(spec.raises(exception))
        spec.then(spec.next()).should_raise(exception)
        spec.then(spec.times_remaining()).should_be(0)
        spec.then(spec.next()).should_raise(UnmetSpecification)
        
        spec = Spec(MockResult(MockCall(MockSpec(), '')))
        exception = ValueError('the number of the counting shall be three')
        spec.when(spec.times(2), spec.raises(exception))
        spec.then(spec.next()).should_raise(exception)
        spec.then(spec.next()).should_raise(exception)
        spec.then(spec.next()).should_raise(UnmetSpecification)

        spec = Spec(MockResult(MockCall(MockSpec(), '')))
        exceptions = (ValueError('the number of the counting shall be three'),
                      ValueError('Four shalt thou not count'))
        spec.when(spec.times(2), spec.raises(*exceptions))
        spec.then(spec.next()).should_raise(exceptions[0])
        spec.then(spec.next()).should_raise(exceptions[1])
        spec.then(spec.next()).should_raise(UnmetSpecification)
开发者ID:gbremer,项目名称:lancelot,代码行数:26,代码来源:mocking_spec.py


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