本文整理汇总了Python中six.assertRegex函数的典型用法代码示例。如果您正苦于以下问题:Python assertRegex函数的具体用法?Python assertRegex怎么用?Python assertRegex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assertRegex函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_source_methods_with_full_model
def test_source_methods_with_full_model(self):
from sherpa.utils.err import IdentifierErr
ui.load_data('full', self.ascii)
ui.set_full_model('full', 'powlaw1d.p1')
# Test Case 1
try:
ui.get_source('full')
except IdentifierErr as e:
six.assertRegex(self, str(e),
"Convolved model\n.*\n is set for dataset full. You should use get_model instead.",
str(e))
try:
ui.plot_source('full')
except IdentifierErr as e:
six.assertRegex(self, str(e),
"Convolved model\n.*\n is set for dataset full. You should use plot_model instead.",
str(e))
# Test Case 2
ui.set_source('full', 'powlaw1d.p2')
ui.get_source('full')
# Test Case 3
ui.load_data('not_full', self.ascii)
try:
ui.get_source('not_full')
except IdentifierErr as e:
self.assertEqual('source not_full has not been set, consider using set_source() or set_model()', str(e))
示例2: test_list_ipblocks
def test_list_ipblocks(self):
ipblocks = self.client.list_ipblocks()
self.assertGreater(len(ipblocks), 0)
self.assertGreater(ipblocks['items'][0]['properties']['size'], 0)
assertRegex(self, ipblocks['items'][0]['id'], self.resource['uuid_match'])
self.assertIn(ipblocks['items'][0]['properties']['location'], self.resource['locations'])
示例3: test_list
def test_list(self):
servers = self.client.list_servers(datacenter_id=self.datacenter['id'])
self.assertGreater(len(servers), 0)
self.assertEqual(servers['items'][0]['type'], 'server')
self.assertTrue(self, len(servers['items'])>0)
assertRegex(self, servers['items'][0]['id'], self.resource['uuid_match'])
示例4: test_panEncryptionAlgo0
def test_panEncryptionAlgo0(self):
pan_in = '4876010123456789012'
panEnc, pan = pci.encrypt(pan_in, None, '00', self.depco)
# self.assertEqual(pan, pan_in.encode('hex'))
six.assertRegex(self, panEnc, r'00\d+')
panClr, data = pci.decrypt(panEnc, self.depco)
self.assertEqual(pan_in, panClr)
示例5: assert_status_of_phase
def assert_status_of_phase(self, output, status, phase, test_name, xfail=None):
"""Asserts that 'output' contains a line showing the given
status for the given phase for the given test_name.
'xfail' should have one of the following values:
- None (the default): assertion passes regardless of whether there is an
EXPECTED/UNEXPECTED string
- 'no': The line should end with the phase, with no additional text after that
- 'expected': After the phase, the line should contain '(EXPECTED FAILURE)'
- 'unexpected': After the phase, the line should contain '(UNEXPECTED'
"""
expected = (r'^ *{} +'.format(re.escape(status)) +
self._test_name_and_phase_regex(test_name, phase))
if xfail == 'no':
# There should be no other text after the testname and phase regex
expected += r' *$'
elif xfail == 'expected':
expected += r' *{}'.format(re.escape(test_status.TEST_EXPECTED_FAILURE_COMMENT))
elif xfail == 'unexpected':
expected += r' *{}'.format(re.escape(test_status.TEST_UNEXPECTED_FAILURE_COMMENT_START))
else:
expect(xfail is None, "Unhandled value of xfail argument")
expected_re = re.compile(expected, flags=re.MULTILINE)
six.assertRegex(self, output, expected_re)
示例6: test_node_default_attrs
def test_node_default_attrs(self):
tasks = [
{'id': 'task-A'},
]
dotgraph = self.get_dotgraph_with_tasks(tasks)
six.assertRegex(self, dotgraph, '"task-A" .*color=yellowgreen.*;')
six.assertRegex(self, dotgraph, '"task-A" .*style=filled.*;')
示例7: testKeyFile
def testKeyFile(self):
# Make sure sha512 appears in returned file documents
resp = self.request('/file/%s' % self.publicFile['_id'])
self.assertStatusOk(resp)
self.assertEqual(resp.json['sha512'], self.publicFile['sha512'])
template = '/file/%s/hashsum_file/%s'
# Test with bad algo
resp = self.request(template % (self.publicFile['_id'], 'foo'))
self.assertStatus(resp, 400)
six.assertRegex(self, resp.json['message'], '^Invalid value for algo: "foo"')
# Should work with public file
resp = self.request(template % (self.publicFile['_id'], 'sha512'),
isJson=False)
self.assertStatusOk(resp)
respBody = self.getBody(resp)
self.assertEqual(respBody, '%s\n' % self.publicFile['sha512'])
self.assertEqual(len(respBody), 129)
# Should not work with private file
resp = self.request(template % (self.privateFile['_id'], 'sha512'))
self.assertStatus(resp, 401)
six.assertRegex(self, resp.json['message'], '^Read access denied')
示例8: test_list_images
def test_list_images(self):
images = self.client.list_images()
assertRegex(self, images['items'][0]['id'], self.resource['uuid_match'])
self.assertGreater(len(images), 0)
self.assertEqual(images['items'][0]['type'], 'image')
self.assertTrue(self, len(images['items']) > 0)
示例9: test_create_complex
def test_create_complex(self):
fwrule = FirewallRule(**self.resource['fwrule'])
nic = NIC(firewall_rules=[fwrule], **self.resource['nic'])
volume = Volume(image=self.image['id'],
image_password='secretpassword123',
ssh_keys=['ssh-rsa AAAAB3NzaC1'],
**self.resource['volume'])
server = Server(
nics=[nic],
create_volumes=[volume],
**self.resource['server'])
composite_server = self.client.create_server(
datacenter_id=self.datacenter['id'],
server=server)
wait_for_completion(self.client, composite_server, 'create_server', wait_timeout=600)
composite_server = self.client.get_server(
datacenter_id=self.datacenter['id'],
server_id=composite_server['id'])
assertRegex(self, composite_server['id'], self.resource['uuid_match'])
self.assertEqual(composite_server['properties']['name'], self.resource['server']['name'])
self.assertEqual(composite_server['properties']['cores'], self.resource['server']['cores'])
self.assertEqual(composite_server['properties']['ram'], self.resource['server']['ram'])
self.assertEqual(composite_server['properties']['availabilityZone'], 'AUTO')
self.assertIn(composite_server['properties']['vmState'], self.resource['vm_states'])
示例10: test_unset_http_equiv_2
def test_unset_http_equiv_2(self):
htmlmeta_hub.pyramid_helpers.htmlmeta_set('refresh', '15', request=self.request)
b = htmlmeta_hub.pyramid_helpers.htmlmeta_as_html(request=self.request)
six.assertRegex(self, b, re_refresh_15)
htmlmeta_hub.pyramid_helpers.htmlmeta_unset('refresh', request=self.request)
b = htmlmeta_hub.pyramid_helpers.htmlmeta_as_html(request=self.request)
self.assertNotRegexpMatches(b, re_refresh_15)
示例11: test_encryptlist
def test_encryptlist(self):
enc_data = best.encryptlist(self.depco,
['67033111201401507', '67033111201401556'],
'20AEC80DEC6474265EA3657B8D8BAA0DEE5058',
key_variant='01', ksk='01',
enc2key='00000000000000201508281410376874')
for elt in enc_data:
six.assertRegex(self, elt, r'^[A-F0-9]{32}$')
示例12: test_encrypt_ecb
def test_encrypt_ecb(self):
e2k, enc_data = best.encrypt(self.depco,
'0102030401020304',
'B426EE161E95AAE7EBE131D4BF63C71F15F2D8',
ksk='01',
enc2key='00000000000000201508281410361909')
six.assertRegex(self, enc_data, r'^[A-F0-9]{16}')
six.assertRegex(self, e2k, r'^[A-F0-9]{32}$')
示例13: assert_status_of_phase
def assert_status_of_phase(self, output, status, phase, test_name):
"""Asserts that 'output' contains a line showing the given
status for the given phase for the given test_name"""
expected = re.compile(r'^ *{} +'.format(re.escape(status)) +
self._test_name_and_phase_regex(test_name, phase),
flags=re.MULTILINE)
six.assertRegex(self, output, expected)
示例14: test_get_ipblock
def test_get_ipblock(self):
ipblock = self.client.get_ipblock(self.ipblock1['id'])
assertRegex(self, ipblock['id'], self.resource['uuid_match'])
self.assertEqual(ipblock['id'], self.ipblock1['id'])
self.assertEqual(ipblock['properties']['name'], (self.resource['ipblock']['name']))
self.assertEqual(ipblock['properties']['size'], self.resource['ipblock']['size'])
self.assertEqual(ipblock['properties']['location'], self.resource['ipblock']['location'])
示例15: test_print_report
def test_print_report(self):
io = six.StringIO()
self.h.print_report(unit=self.unit, file=io)
expect = r'''\AFunctionName UsedBytes AcquiredBytes Occurrence
+Exp +[0-9.\-e]+.?B +[0-9.\-e]+.?B +[0-9]+
+ReLU +[0-9.\-e]+.?B +[0-9.\-e]+.?B +[0-9]+$
'''
actual = io.getvalue()
six.assertRegex(self, actual, expect)