• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python testing.failure函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python shortcuts.must_have_permission函数代码示例发布时间:2022-05-24
下一篇:
Python expects.raise_error函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap