当前位置: 首页>>代码示例>>Python>>正文


Python pyassert.assert_that函数代码示例

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


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


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