本文整理汇总了Python中expects.testing.failure函数的典型用法代码示例。如果您正苦于以下问题:Python failure函数的具体用法?Python failure怎么用?Python failure使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了failure函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_should_fail_if_actual_has_expected_header_without_value
def test_should_fail_if_actual_has_expected_header_without_value(self):
with failure(
self.response,
"to have header {!r} with value {!r} but was".format(IRRELEVANT_HEADER_KEY1, IRRELEVANT_HEADER_VALUE3),
):
expect(response=self.response).to.have.header(IRRELEVANT_HEADER_KEY1, IRRELEVANT_HEADER_VALUE3)
开发者ID:izamarro,项目名称:requests-expects,代码行数:7,代码来源:test_header.py
示例2: 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)
def it_should_fail_if_actual_has_key_in_dict_with_value():
with failure(_.dct, "not to have key 'bar' with value 0 but was 0"):
expect(_.dct).not_to.have.keys({'bar': 0, 'foo': 1})
开发者ID:aleasoluciones,项目名称:expects,代码行数:7,代码来源:keys_spec.py
示例3: test_should_fail_if_actual_has_expected_header_and_value
def test_should_fail_if_actual_has_expected_header_and_value(self):
with failure(
self.response,
"not to have header {!r} with value {!r}".format(IRRELEVANT_HEADER_KEY1, IRRELEVANT_HEADER_VALUE1),
):
expect(response=self.response).not_to.have.header(IRRELEVANT_HEADER_KEY1, IRRELEVANT_HEADER_VALUE1)
开发者ID:izamarro,项目名称:requests-expects,代码行数:7,代码来源:test_header.py
示例4: test_should_fail_if_actual_has_header_without_value_in_kwargs
def test_should_fail_if_actual_has_header_without_value_in_kwargs(self):
with failure(self.response,
"to have header 'content-length' with value '25'"):
expect(response=self.response).to.have.headers(
content_type=IRRELEVANT_HEADER_VALUE1,
content_length='25')
开发者ID:izamarro,项目名称:requests-expects,代码行数:7,代码来源:test_headers.py
示例5: 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)
开发者ID:aleasoluciones,项目名称:expects,代码行数:10,代码来源:raise_error_spec.py
示例6: it_should_fail_if_actual_raises_but_message_does_not_match_pattern
def it_should_fail_if_actual_raises_but_message_does_not_match_pattern():
pattern = r'\W+ error'
def callback():
raise AttributeError(_.message)
with failure(callback, "to raise AttributeError with "
"message {} but message was {}"
.format(repr(pattern), repr(_.message))):
expect(callback).to.raise_error(AttributeError, pattern)
开发者ID:aleasoluciones,项目名称:expects,代码行数:11,代码来源:raise_error_spec.py
示例7: callback
def callback():
with failure(have_length(0)):
raise AssertionError('foo')
开发者ID:BooleanCat,项目名称:expects,代码行数:3,代码来源:failure_spec.py
示例8: expect
expect(callback).to(raise_error(AssertionError))
with it('fails if another exception raised'):
def callback():
with failure:
raise KeyError()
expect(callback).to(raise_error(AssertionError))
with context('with message'):
with before.each:
self.message = "to be 'bar'"
self.pattern = "to be '\w+'"
with it('passes if assertion raised and message ends with'):
with failure(self.message):
raise AssertionError("Expected 'foo' {0}".format(self.message))
with it('passes if assertion error raised and message matches'):
with failure(match(self.pattern)):
raise AssertionError("Expected 'foo' {0}".format(self.message))
with it('passes if assertion error raised and message has length 0'):
with failure(have_length(0)):
raise AssertionError('')
with it('fails if assertion error not raised'):
def callback():
with failure(self.message):
pass
开发者ID:BooleanCat,项目名称:expects,代码行数:30,代码来源:failure_spec.py
示例9: describe
# -*- coding: utf-8 -*
from expects import *
from expects.testing import failure
with describe('be_above_or_equal'):
with it('should pass if number is above expected'):
expect(5).to(be_above_or_equal(4))
with it('should pass if number equals expected'):
expect(5).to(be_above_or_equal(5))
with it('should fail if number is not above or equal expected'):
with failure('expected: 1 to be above or equal 4'):
expect(1).to(be_above_or_equal(4))
with context('when negated'):
with it('should pass if number is not above or equal expected'):
expect(1).not_to(be_above_or_equal(4))
with it('should fail if number is above expected'):
with failure('expected: 5 not to be above or equal 4'):
expect(5).not_to(be_above_or_equal(4))
with it('should fail if number equals expected'):
with failure('expected: 5 not to be above or equal 5'):
expect(5).not_to(be_above_or_equal(5))
开发者ID:BooleanCat,项目名称:expects,代码行数:28,代码来源:be_above_or_equal_spec.py
示例10: it_should_fail_if_actual_iterable_does_not_have_the_expected_length
def it_should_fail_if_actual_iterable_does_not_have_the_expected_length():
actual = iter('foo')
with failure(actual, 'to have length 2 but was 3'):
expect(actual).to.have.length(2)
开发者ID:aleasoluciones,项目名称:expects,代码行数:5,代码来源:length_spec.py
示例11: it_should_fail_if_actual_is_not_above_expected
def it_should_fail_if_actual_is_not_above_expected():
with failure(1, 'to be above 4'):
expect(1).to.be.above(4)
开发者ID:aleasoluciones,项目名称:expects,代码行数:3,代码来源:above_spec.py
示例12: it_should_fail_if_actual_is_false
def it_should_fail_if_actual_is_false():
with failure(False, "to be True"):
expect(False).to.be.true
开发者ID:javierj,项目名称:expects,代码行数:3,代码来源:true_spec.py
示例13: describe
# -*- coding: utf-8 -*
from expects import *
from expects.testing import failure
with describe("be_false"):
with it("should pass if object is false"):
expect(False).to(be_false)
with it("should fail if object is true"):
with failure("Expected True to be false"):
expect(True).to(be_false)
with context("#negated"):
with it("should pass if object is not false"):
expect(True).not_to(be_false)
with it("should fail if object is false"):
with failure("Expected False not to be false"):
expect(False).not_to(be_false)
开发者ID:nilwer,项目名称:expects,代码行数:21,代码来源:be_false_spec.py
示例14: describe
from expects.testing import failure
with describe('have_len'):
with it('passes if string has the expected length'):
expect('foo').to(have_len(3))
with it('passes if string has length matching'):
expect('foo').to(have_len(above_or_equal(3)))
with it('passes if iterable has the expected length'):
expect(iter('foo')).to(have_len(3))
with it('fails if string does not have the expected length'):
with failure("but: was 3"):
expect('foo').to(have_len(2))
with it('fails if string does not have length matching'):
with failure("but: was 3"):
expect('foo').to(have_len(below(3)))
with it('fails if iterable does not have the expected length'):
with failure("but: was 3"):
expect(iter('foo')).to(have_len(2))
with context('when negated'):
with it('passes if string does not have the expected length'):
expect('foo').not_to(have_len(2))
with it('fails if string has the expected length'):
开发者ID:BooleanCat,项目名称:expects,代码行数:30,代码来源:have_len_spec.py
示例15: it_should_fail_if_actual_has_property_in_kwargs_but_not_in_args
def it_should_fail_if_actual_has_property_in_kwargs_but_not_in_args():
with failure(_.obj, "not to have property 'bar' with value 0 but was 0"):
expect(_.obj).not_to.have.properties('foo', bar=0)
开发者ID:aleasoluciones,项目名称:expects,代码行数:3,代码来源:properties_spec.py
示例16: it_should_fail_if_actual_has_property_in_dict_with_value
def it_should_fail_if_actual_has_property_in_dict_with_value():
with failure(_.obj, "not to have property 'bar' with value 0 but was 0"):
expect(_.obj).not_to.have.properties({'bar': 0, 'foo': 1})
开发者ID:aleasoluciones,项目名称:expects,代码行数:3,代码来源:properties_spec.py
示例17: 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
开发者ID:javierj,项目名称:expects,代码行数:3,代码来源:true_spec.py
示例18: it_should_fail_if_actual_is_above_expected
def it_should_fail_if_actual_is_above_expected():
with failure(5, 'not to be above 4'):
expect(5).not_to.be.above(4)
开发者ID:aleasoluciones,项目名称:expects,代码行数:3,代码来源:above_spec.py
示例19: describe
# -*- coding: utf-8 -*
from expects import *
from expects.testing import failure
with describe('be_below'):
with it('should pass if number is below expected'):
expect(1).to(be_below(4))
with it('should fail if number is not below expected'):
with failure('expected: 4 to be below 1'):
expect(4).to(be_below(1))
with context('#negated'):
with it('should pass if number is not below expected'):
expect(4).not_to(be_below(1))
with it('should fail if number is below expected'):
with failure('expected: 1 not to be below 4'):
expect(1).not_to(be_below(4))
开发者ID:BooleanCat,项目名称:expects,代码行数:21,代码来源:be_below_spec.py
示例20: 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)
开发者ID:aleasoluciones,项目名称:expects,代码行数:5,代码来源:length_spec.py
注:本文中的expects.testing.failure函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论