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


Python Spec.should_not_raise方法代碼示例

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


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

示例1: override_comparators_dont_replace_all

# 需要導入模塊: from lancelot import Spec [as 別名]
# 或者: from lancelot.Spec import should_not_raise [as 別名]
 def override_comparators_dont_replace_all(self):
     ''' comparator overrides only affect comparator used for that type '''
     mock_spec = MockSpec(comparators={float:EqualsEquals})
     mock_call = mock_spec.your_mother(TypeError('hamster'))
     mock_call_result = mock_call.result_of('your_mother')
     spec = Spec(mock_call_result)
     spec.__call__(TypeError('hamster'))
     spec.should_not_raise(UnmetSpecification)
開發者ID:gbremer,項目名稱:lancelot,代碼行數:10,代碼來源:mocking_spec.py

示例2: correct_result_should_be_ok

# 需要導入模塊: from lancelot import Spec [as 別名]
# 或者: from lancelot.Spec import should_not_raise [as 別名]
 def correct_result_should_be_ok(self):
     ''' Specified and_result="bar" and was "bar": met specification.
     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('bar'), 
                                 and_result='bar'))
     spec.verify(lambda: mock_spec.foo())
     spec.should_not_raise(UnmetSpecification)
開發者ID:gbremer,項目名稱:lancelot,代碼行數:12,代碼來源:constraint_spec.py

示例3: should_check_unverified_collaborations

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

示例4: verify_exceptions_with_comparator

# 需要導入模塊: from lancelot import Spec [as 別名]
# 或者: from lancelot.Spec import should_not_raise [as 別名]
 def verify_exceptions_with_comparator(self):
     ''' ExceptionValue should be used to verify Exception args '''
     mock_call = MockSpec().your_mother(TypeError('hamster'))
     mock_call_result = mock_call.result_of('your_mother')
     spec = Spec(mock_call_result)
     spec.__call__(TypeError('hamster'))
     spec.should_not_raise(UnmetSpecification)
     
     mock_call = MockSpec().your_father(smelt_of=TypeError('elderberries'))
     mock_call_result = mock_call.result_of('your_father')
     spec = Spec(mock_call_result)
     spec.__call__(smelt_of=TypeError('elderberries'))
     spec.should_not_raise(UnmetSpecification)
開發者ID:gbremer,項目名稱:lancelot,代碼行數:15,代碼來源:mocking_spec.py

示例5: correct_call_should_be_ok

# 需要導入模塊: from lancelot import Spec [as 別名]
# 或者: from lancelot.Spec import should_not_raise [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.should_not_raise方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。