本文整理汇总了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
示例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)
示例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()
示例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)
示例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")
示例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()
示例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")
示例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")
示例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)
示例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()
示例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)
示例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)
示例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])
示例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"})
示例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)