本文整理汇总了Python中spec.helpers.failure函数的典型用法代码示例。如果您正苦于以下问题:Python failure函数的具体用法?Python failure怎么用?Python failure使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了failure函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: it_should_fail_if_actual_raises_expected_exception_with_message
def it_should_fail_if_actual_raises_expected_exception_with_message():
message = 'Foo error'
failure_message = 'not to raise AttributeError with message {} but message was {}'.format(
repr(message), repr(message))
def callback():
raise AttributeError(message)
with failure(callback, failure_message):
expect(callback).not_to.raise_error(AttributeError, message)
示例2: it_should_fail_if_actual_is_greater_than_expected_
def it_should_fail_if_actual_is_greater_than_expected_():
with failure(5, 'not to be greater or equal to 4'):
expect(5).not_to.be.greater_or_equal_to(4)
示例3: it_should_fail_if_actual_does_not_equal_expected_
def it_should_fail_if_actual_does_not_equal_expected_():
with failure(1, 'to be equal 2'):
expect(1).to.be.equal(2)
示例4: it_should_fail_if_actual_has_the_expected_length
def it_should_fail_if_actual_has_the_expected_length():
actual = 'foo'
with failure(actual, 'not to have length 3 but was 3'):
expect(actual).not_to.have.length(3)
示例5: it_should_fail_if_actual_has_key_in_kwargs_but_not_in_args
def it_should_fail_if_actual_has_key_in_kwargs_but_not_in_args():
with failure(_.dct, "not to have key 'bar' with value 0 but was 0"):
expect(_.dct).not_to.have.keys('foo', bar=0)
示例6: it_should_fail_if_actual_has_key_in_kwargs_with_value
def it_should_fail_if_actual_has_key_in_kwargs_with_value():
with failure(_.dct, "not to have key 'bar' with value 0 but was 0"):
expect(_.dct).not_to.have.keys(baz=0, bar=0)
示例7: it_should_fail_if_actual_raises_expected_exception_with_different_message
def it_should_fail_if_actual_raises_expected_exception_with_different_message():
def callback():
raise AttributeError('bar')
with failure(callback, "to raise AttributeError with message 'foo' but message was 'bar'"):
expect(callback).to.raise_error(AttributeError, 'foo')
示例8: it_should_fail_if_actual_has_expected_key
def it_should_fail_if_actual_has_expected_key():
with failure(_.dct, "not to have key 'bar'"):
expect(_.dct).not_to.have.key('bar')
示例9: it_should_fail_if_actual_is_true_
def it_should_fail_if_actual_is_true_():
with failure(True, 'not to be True'):
expect(True).not_to.be.true
示例10: it_should_fail_if_actual_is_within_expected_range
def it_should_fail_if_actual_is_within_expected_range():
with failure(5, 'not to be within 4, 7'):
expect(5).not_to.be.within(4, 7)
示例11: it_should_fail_if_actual_does_not_raise_exception
def it_should_fail_if_actual_does_not_raise_exception():
callback = lambda: None
with failure(callback, 'to raise AttributeError but None raised'):
expect(callback).to.raise_error(AttributeError)
示例12: it_should_fail_if_actual_is_equal_to_expected_
def it_should_fail_if_actual_is_equal_to_expected_():
with failure(5, 'not to be less or equal to 5'):
expect(5).not_to.be.less_or_equal_to(5)
示例13: it_should_fail_if_actual_is_less_than_expected_
def it_should_fail_if_actual_is_less_than_expected_():
with failure(1, 'not to be less or equal to 4'):
expect(1).not_to.be.less_or_equal_to(4)
示例14: it_should_fail_if_actual_is_less_than_expected
def it_should_fail_if_actual_is_less_than_expected():
with failure(1, 'not to be less than 4'):
expect(1).not_to.be.less_than(4)
示例15: it_should_fail_if_actual_is_equal_to_expected
def it_should_fail_if_actual_is_equal_to_expected():
with failure(5, 'not to be greater or equal to 5'):
expect(5).not_to.be.greater_or_equal_to(5)