當前位置: 首頁>>代碼示例>>Python>>正文


Python Spec.include方法代碼示例

本文整理匯總了Python中lancelot.Spec.include方法的典型用法代碼示例。如果您正苦於以下問題:Python Spec.include方法的具體用法?Python Spec.include怎麽用?Python Spec.include使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在lancelot.Spec的用法示例。


在下文中一共展示了Spec.include方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: should_increment

# 需要導入模塊: from lancelot import Spec [as 別名]
# 或者: from lancelot.Spec import include [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

示例2: all_verif_failfast_behaviour

# 需要導入模塊: from lancelot import Spec [as 別名]
# 或者: from lancelot.Spec import include [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

示例3: should_return_all_results

# 需要導入模塊: from lancelot import Spec [as 別名]
# 或者: from lancelot.Spec import include [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

示例4: should_verify_each_item

# 需要導入模塊: from lancelot import Spec [as 別名]
# 或者: from lancelot.Spec import include [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

示例5: notification_behaviour

# 需要導入模塊: from lancelot import Spec [as 別名]
# 或者: from lancelot.Spec import include [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

示例6: all_verif_include_behaviour

# 需要導入模塊: from lancelot import Spec [as 別名]
# 或者: from lancelot.Spec import include [as 別名]
def all_verif_include_behaviour():
    ''' include() method should return self '''
    all_verifiable = silent_listener()
    spec = Spec(all_verifiable)
    spec.include(string_abc).should_be(all_verifiable)
開發者ID:gbremer,項目名稱:lancelot,代碼行數:7,代碼來源:verification_spec.py

示例7: should_ignore_duplicates

# 需要導入模塊: from lancelot import Spec [as 別名]
# 或者: from lancelot.Spec import include [as 別名]
 def should_ignore_duplicates(self):
     ''' total() should ignore duplicate include()s '''
     spec = Spec(AllVerifiable, given=silent_listener)
     spec.when(spec.include(raise_index_error),
               spec.include(raise_index_error))
     spec.then(spec.total()).should_be(1)
開發者ID:gbremer,項目名稱:lancelot,代碼行數:8,代碼來源:verification_spec.py


注:本文中的lancelot.Spec.include方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。