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

Python pyassert.assert_that函数代码示例

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

本文整理汇总了Python中pyassert.assert_that函数的典型用法代码示例。如果您正苦于以下问题:Python assert_that函数的具体用法?Python assert_that怎么用?Python assert_that使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了assert_that函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: parse_p

def parse_p(p, category):
    judgment_type = CATEGORY_TO_JUDGMENT_TYPE[category]
    judgment_name = CATEGORY_TO_JUDGMENT_NAME.get(category) or category

    lines = list(p.stripped_strings)
    assert_that(len(lines)).ge(2).le(4)

    name = lines[0]
    if name.endswith(' - ON STRIKE'):
        name = name[:-12]

    if len(lines) <= 2:
        address = parse_addr(lines[1:2])
    else:
        address = parse_addr(lines[1:3])

    if len(lines) >= 4:
        assert_that(lines[3]).starts_with('Phone: ')
        address.set('telephone', lines[3][7:])

    hotel = Item('Hotel')
    hotel.set('name', name)
    hotel.set('address', address)

    judgment = Item('Judgment')
    judgment.set('judgmentType', judgment_type)
    judgment.set('name', judgment_name)
    judgment.set('target', hotel)

    return judgment
开发者ID:davidmarin,项目名称:pbg,代码行数:30,代码来源:uhg.py


示例2: constructor_should_raise_exception_when_config_does_not_contain_expected_section

def constructor_should_raise_exception_when_config_does_not_contain_expected_section(temp_dir):
    temp_dir.create_file("config.cfg", "[spam]\nspam=eggs")

    def callback():
        Configuration(temp_dir.join("config.cfg"))

    assert_that(callback).raises(ValueError)
开发者ID:andante-project,项目名称:pypiproxy,代码行数:7,代码来源:configuration_pyfix_tests.py


示例3: should_send_index_result

def should_send_index_result(web_application):
    when(webapp).get_package_statistics().thenReturn((0, 0))
    response = web_application.get("/")

    assert_that(response.status_code).is_equal_to(200)

    verify(webapp).get_package_statistics()
开发者ID:andante-project,项目名称:pypiproxy,代码行数:7,代码来源:webapp_pyfix_tests.py


示例4: constructor_should_raise_exception_when_config_file_has_invalid_content

def constructor_should_raise_exception_when_config_file_has_invalid_content(temp_dir):
    temp_dir.create_file("config.cfg", "spam")

    def callback():
        Configuration(temp_dir.join("config.cfg"))

    assert_that(callback).raises(ValueError)
开发者ID:andante-project,项目名称:pypiproxy,代码行数:7,代码来源:configuration_pyfix_tests.py


示例5: integration_test_with_hosted_file

def integration_test_with_hosted_file():
    with LiveServer() as liveserver:
        liveserver.create_hosted_file("pyassert-0.1.2.tar.gz")

        index_page = download(liveserver.url + "simple/")

        assert_that(index_page).contains("pyassert")
开发者ID:andante-project,项目名称:pypiproxy,代码行数:7,代码来源:should_render_index_using_stored_files_tests.py


示例6: integration_test

def integration_test():
    with LiveServer() as liveserver:
        status_code = upload().file("schnulli.tar.gz").file_content("Hello world") \
                              .package_name("foobar").package_version("1.0.0").to(liveserver)

        assert_that(status_code).is_equal_to(OK)
        assert_that("target/integrationtest/packages/hosted/foobar-1.0.0.tar.gz").is_a_file()
开发者ID:andante-project,项目名称:pypiproxy,代码行数:7,代码来源:should_store_uploaded_file_tests.py


示例7: integration_test_with_hosted_file

def integration_test_with_hosted_file():
    with LiveServer() as liveserver:
        liveserver.create_hosted_file("yadt-1.2.3.tar.gz")

        actual_content = download(liveserver.url + "package/yadt/1.2.3/yadt-1.2.3.tar.gz")

        assert_that(actual_content).is_equal_to("hosted content")
开发者ID:andante-project,项目名称:pypiproxy,代码行数:7,代码来源:should_offer_stored_files_for_download_tests.py


示例8: should_return_given_hosted_packages_directory_when_packages_directory_option_is_given

def should_return_given_hosted_packages_directory_when_packages_directory_option_is_given(temp_dir):

    temp_dir.create_file("config.cfg",
        "[{0}]\n{1}=packages/hosted".format(Configuration.SECTION, Configuration.OPTION_HOSTED_PACKAGES_DIRECTORY))

    config = Configuration(temp_dir.join("config.cfg"))
    assert_that(config.hosted_packages_directory).is_equal_to("packages/hosted")
开发者ID:andante-project,项目名称:pypiproxy,代码行数:7,代码来源:configuration_pyfix_tests.py


示例9: test_should_not_validate_project_with_runtime_dependency_being_also_given_as_build_dependency

    def test_should_not_validate_project_with_runtime_dependency_being_also_given_as_build_dependency (self):
        self.project.depends_on('spam')
        self.project.build_depends_on('spam')
        validation_messages = self.project.validate()

        assert_that(validation_messages).contains("Runtime dependency 'spam' has also been given as build dependency.")
        assert_that(len(validation_messages)).equals(1)
开发者ID:Vanuan,项目名称:pybuilder,代码行数:7,代码来源:core_tests.py


示例10: list_versions_should_return_empty_list_when_no_package_files_are_found

def list_versions_should_return_empty_list_when_no_package_files_are_found(temp_dir):
    temp_dir.create_directory("packages")

    index = PackageIndex("any_name", temp_dir.join("packages"))
    versions = [v for v in index.list_versions("spam")]

    assert_that(versions).is_empty()
开发者ID:yadt,项目名称:pypiproxy,代码行数:7,代码来源:packageindex_pyfix_tests.py


示例11: add_package_should_write_package_file

def add_package_should_write_package_file(temp_dir, package_data):
    index = PackageIndex("any_name", temp_dir.join("packages"))
    index.add_package("spam", "version", package_data)

    expected_file_name = temp_dir.join("packages", "spam-version.tar.gz")
    assert_that(expected_file_name).is_a_file()
    assert_that(expected_file_name).has_file_length_of(17)
开发者ID:yadt,项目名称:pypiproxy,代码行数:7,代码来源:packageindex_pyfix_tests.py


示例12: test_resumeTorrents_by_hashlist

def test_resumeTorrents_by_hashlist():
    sut = QBitTorrent("admin", "adminadmin")
    sut.__POST__ = MagicMock(name="post")

    sut.resumeTorrents(hashes=["2", "3", "4"])

    assert_that(sut.__POST__.call_count).is_equal_to(3)
开发者ID:raghur,项目名称:qbittorrent.py,代码行数:7,代码来源:test_qbittorrent.py


示例13: test_should_register_interceptor

    def test_should_register_interceptor(self):
        def some_interceptor(): pass

        @before(some_interceptor)
        def some_test(): pass

        assert_that(getattr(some_test, BEFORE_ATTRIBUTE)).is_equal_to([some_interceptor])
开发者ID:pyclectic,项目名称:pyfix,代码行数:7,代码来源:decorators_tests.py


示例14: test_ensure_that_single_two_decorators_with_multiple_fixtures_are_handled

    def test_ensure_that_single_two_decorators_with_multiple_fixtures_are_handled(self):
        @given(spam="spam", eggs="eggs")
        @given(foo="foo")
        def some_function():
            pass

        assert_that(getattr(some_function, GIVEN_ATTRIBUTE)).equals({"spam": "spam", "eggs": "eggs", "foo": "foo"})
开发者ID:pyclectic,项目名称:pyfix,代码行数:7,代码来源:decorators_tests.py


示例15: test_should_not_validate_project_with_duplicate_build_dependency_for_more_than_two_times

    def test_should_not_validate_project_with_duplicate_build_dependency_for_more_than_two_times (self):
        self.project.build_depends_on('spam', version='1')
        self.project.build_depends_on('spam', version='2')
        self.project.build_depends_on('spam', version='3')
        validation_messages = self.project.validate()

        assert_that(validation_messages).contains("Build dependency 'spam' has been defined multiple times.")
        assert_that(len(validation_messages)).equals(1)
开发者ID:Vanuan,项目名称:pybuilder,代码行数:8,代码来源:core_tests.py


示例16: test_should_not_validate_project_with_duplicate_dependency_for_more_than_two_times

    def test_should_not_validate_project_with_duplicate_dependency_for_more_than_two_times(self):
        self.project.depends_on("spam", version="1")
        self.project.depends_on("spam", version="2")
        self.project.depends_on("spam", version="3")
        validation_messages = self.project.validate()

        assert_that(validation_messages).contains("Runtime dependency 'spam' has been defined multiple times.")
        assert_that(len(validation_messages)).equals(1)
开发者ID:Hawks12,项目名称:pybuilder,代码行数:8,代码来源:core_tests.py


示例17: test_get_torrents_should_filter_by_func

def test_get_torrents_should_filter_by_func():
    sut = QBitTorrent("admin", "adminadmin")
    sut.__GET__ = MagicMock(name="__GET__")
    sut.__GET__.return_value = list([{"state": "downloading"}, {"state": "pausedDL"}])

    torrents = sut.getTorrents(lambda x: x["state"] == "downloading")
    assert_that(generator_len(torrents)).is_equal_to(1)
    sut.__GET__.assert_called_with("/json/torrents")
开发者ID:raghur,项目名称:qbittorrent.py,代码行数:8,代码来源:test_qbittorrent.py


示例18: should_send_not_found_when_trying_to_get_package_content_for_nonexisting_package

def should_send_not_found_when_trying_to_get_package_content_for_nonexisting_package(web_application):
    when(webapp).get_package_content(any_value(), any_value()).thenReturn(None)

    response = web_application.get("/package/package_name/version/package_name-version.tar.gz")

    assert_that(response.status_code).is_equal_to(404)

    verify(webapp).get_package_content("package_name", "version")
开发者ID:andante-project,项目名称:pypiproxy,代码行数:8,代码来源:webapp_pyfix_tests.py


示例19: test_should_invoke_test_function_twice_when_fixture_provides_two_values

    def test_should_invoke_test_function_twice_when_fixture_provides_two_values(self):
        function = InvocationCountingFunctionMock()
        test_definition = TestDefinition(function, "unittest", "unittest", "module",
                {"spam": enumerate("spam", "eggs")})

        self.injector.execute_test(test_definition)

        assert_that(function.invocation_counter).equals(2)
开发者ID:pyclectic,项目名称:pyfix,代码行数:8,代码来源:testrunner_tests.py


示例20: test_ensure_that_test_is_marked_as_failing_and_exception_type_in_message_when_some_exception_raised

    def test_ensure_that_test_is_marked_as_failing_and_exception_type_in_message_when_some_exception_raised(self):
        function = InvocationCountingFunctionMock(Exception("Caboom"))
        test_definition = TestDefinition(function, "unittest", "unittest", "module", {})

        actual = self.injector.execute_test(test_definition)

        assert_that(actual[0].success).is_false()
        assert_that(actual[0].message).equals("Exception: Caboom")
开发者ID:pyclectic,项目名称:pyfix,代码行数:8,代码来源:testrunner_tests.py



注:本文中的pyassert.assert_that函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python pyatom.AtomFeed类代码示例发布时间:2022-05-25
下一篇:
Python pem.readBase64fromText函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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