本文整理汇总了Python中testtools.matchers.StartsWith方法的典型用法代码示例。如果您正苦于以下问题:Python matchers.StartsWith方法的具体用法?Python matchers.StartsWith怎么用?Python matchers.StartsWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testtools.matchers
的用法示例。
在下文中一共展示了matchers.StartsWith方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_preseed_url_for_known_node_local_ip_no_subnet
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import StartsWith [as 别名]
def test_preseed_url_for_known_node_local_ip_no_subnet(self):
rack_url = "http://%s" % factory.make_name("host")
network = IPNetwork("10.1.1/24")
local_ip = factory.pick_ip_in_network(network)
remote_ip = factory.make_ip_address()
self.patch(server_address, "resolve_hostname").return_value = {
local_ip
}
rack_controller = factory.make_RackController(url=rack_url)
node = self.make_node(primary_rack=rack_controller)
mac = node.get_boot_interface().mac_address
self.patch_autospec(boot_module, "event_log_pxe_request")
observed_config = get_config(
rack_controller.system_id, local_ip, remote_ip, mac=mac
)
self.assertThat(
observed_config["preseed_url"],
StartsWith("http://%s:5248" % local_ip),
)
示例2: test_preseed_url_for_known_node_local_ip_subnet_with_dns
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import StartsWith [as 别名]
def test_preseed_url_for_known_node_local_ip_subnet_with_dns(self):
rack_url = "http://%s" % factory.make_name("host")
subnet = factory.make_Subnet()
local_ip = factory.pick_ip_in_Subnet(subnet)
remote_ip = factory.make_ip_address()
self.patch(server_address, "resolve_hostname").return_value = {
local_ip
}
rack_controller = factory.make_RackController(url=rack_url)
node = self.make_node(primary_rack=rack_controller)
mac = node.get_boot_interface().mac_address
self.patch_autospec(boot_module, "event_log_pxe_request")
observed_config = get_config(
rack_controller.system_id, local_ip, remote_ip, mac=mac
)
self.assertThat(
observed_config["preseed_url"],
StartsWith("http://%s:5248" % local_ip),
)
示例3: test_capitalized_headers
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import StartsWith [as 别名]
def test_capitalized_headers(self):
self.repo.commit()
self.repo.tag('1.2.3')
self.repo.commit('Sem-Ver: api-break')
version = packaging._get_version_from_git()
self.assertThat(version, matchers.StartsWith('2.0.0.dev1'))
示例4: test_capitalized_headers_partial
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import StartsWith [as 别名]
def test_capitalized_headers_partial(self):
self.repo.commit()
self.repo.tag('1.2.3')
self.repo.commit('Sem-ver: api-break')
version = packaging._get_version_from_git()
self.assertThat(version, matchers.StartsWith('2.0.0.dev1'))
示例5: test_non_canonical_tagged_version_bump
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import StartsWith [as 别名]
def test_non_canonical_tagged_version_bump(self):
self.repo.commit()
self.repo.tag('1.4')
self.repo.commit('Sem-Ver: api-break')
version = packaging._get_version_from_git()
self.assertThat(version, matchers.StartsWith('2.0.0.dev1'))
示例6: test_untagged_version_has_dev_version_postversion
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import StartsWith [as 别名]
def test_untagged_version_has_dev_version_postversion(self):
self.repo.commit()
self.repo.tag('1.2.3')
self.repo.commit()
version = packaging._get_version_from_git()
self.assertThat(version, matchers.StartsWith('1.2.4.dev1'))
示例7: test_untagged_pre_release_has_pre_dev_version_postversion
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import StartsWith [as 别名]
def test_untagged_pre_release_has_pre_dev_version_postversion(self):
self.repo.commit()
self.repo.tag('1.2.3.0a1')
self.repo.commit()
version = packaging._get_version_from_git()
self.assertThat(version, matchers.StartsWith('1.2.3.0a2.dev1'))
示例8: test_untagged_version_major_bump
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import StartsWith [as 别名]
def test_untagged_version_major_bump(self):
self.repo.commit()
self.repo.tag('1.2.3')
self.repo.commit('sem-ver: api-break')
version = packaging._get_version_from_git()
self.assertThat(version, matchers.StartsWith('2.0.0.dev1'))
示例9: test_untagged_version_has_dev_version_preversion
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import StartsWith [as 别名]
def test_untagged_version_has_dev_version_preversion(self):
self.repo.commit()
self.repo.tag('1.2.3')
self.repo.commit()
version = packaging._get_version_from_git('1.2.5')
self.assertThat(version, matchers.StartsWith('1.2.5.dev1'))
示例10: test_untagged_version_after_pre_has_dev_version_preversion
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import StartsWith [as 别名]
def test_untagged_version_after_pre_has_dev_version_preversion(self):
self.repo.commit()
self.repo.tag('1.2.3.0a1')
self.repo.commit()
version = packaging._get_version_from_git('1.2.5')
self.assertThat(version, matchers.StartsWith('1.2.5.dev1'))
示例11: test_untagged_version_after_rc_has_dev_version_preversion
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import StartsWith [as 别名]
def test_untagged_version_after_rc_has_dev_version_preversion(self):
self.repo.commit()
self.repo.tag('1.2.3.0a1')
self.repo.commit()
version = packaging._get_version_from_git('1.2.3')
self.assertThat(version, matchers.StartsWith('1.2.3.0a2.dev1'))
示例12: test_preversion_too_low_simple
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import StartsWith [as 别名]
def test_preversion_too_low_simple(self):
# That is, the target version is either already released or not high
# enough for the semver requirements given api breaks etc.
self.repo.commit()
self.repo.tag('1.2.3')
self.repo.commit()
# Note that we can't target 1.2.3 anymore - with 1.2.3 released we
# need to be working on 1.2.4.
err = self.assertRaises(
ValueError, packaging._get_version_from_git, '1.2.3')
self.assertThat(err.args[0], matchers.StartsWith('git history'))
示例13: assert_starts_with
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import StartsWith [as 别名]
def assert_starts_with(self, expected_prefix, observed_str, msg=None):
self.assertThat(observed_str,
matchers.StartsWith(expected_prefix), msg)
示例14: test_tacker_context_create
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import StartsWith [as 别名]
def test_tacker_context_create(self):
ctx = context.Context('user_id', 'tenant_id')
self.assertEqual('user_id', ctx.user_id)
self.assertEqual('tenant_id', ctx.project_id)
self.assertEqual('tenant_id', ctx.tenant_id)
self.assertThat(ctx.request_id, matchers.StartsWith('req-'))
self.assertEqual('user_id', ctx.user_id)
self.assertEqual('tenant_id', ctx.project_id)
self.assertIsNone(ctx.user_name)
self.assertIsNone(ctx.tenant_name)
示例15: test_timestamp_invalid
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import StartsWith [as 别名]
def test_timestamp_invalid(self):
test_property_schema = {'type': 'timestamp'}
# invalid timestamp - day out of range
value = '2015-04-115T02:59:43.1Z'
propertyInstance = Property('test_property', value,
test_property_schema)
error = self.assertRaises(ValueError, propertyInstance.validate)
expected_message = (_('"%s" is not a valid timestamp.') % value)
self.assertThat(str(error), matchers.StartsWith(expected_message))