本文整理汇总了Python中six.assertRegex方法的典型用法代码示例。如果您正苦于以下问题:Python six.assertRegex方法的具体用法?Python six.assertRegex怎么用?Python six.assertRegex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类six
的用法示例。
在下文中一共展示了six.assertRegex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_default_oauth2_urls
# 需要导入模块: import six [as 别名]
# 或者: from six import assertRegex [as 别名]
def test_default_oauth2_urls(self):
flow_obj = DropboxOAuth2Flow('dummy_app_key', 'dummy_app_secret',
'http://localhost/dummy', 'dummy_session', 'dbx-auth-csrf-token')
six.assertRegex(
self,
flow_obj._get_authorize_url('http://localhost/redirect', 'state', 'legacy'),
r'^https://{}/oauth2/authorize\?'.format(re.escape(session.WEB_HOST)),
)
self.assertEqual(
flow_obj.build_url('/oauth2/authorize'),
'https://{}/oauth2/authorize'.format(session.API_HOST),
)
self.assertEqual(
flow_obj.build_url('/oauth2/authorize', host=session.WEB_HOST),
'https://{}/oauth2/authorize'.format(session.WEB_HOST),
)
示例2: testSetup
# 需要导入模块: import six [as 别名]
# 或者: from six import assertRegex [as 别名]
def testSetup(self, _mock_TurbiniaClient):
"""Tests that the processor is set up correctly."""
test_state = state.DFTimewolfState(config.Config)
turbinia_processor = turbinia.TurbiniaProcessor(test_state)
turbinia_processor.SetUp(
disk_name='disk-1',
project='turbinia-project',
turbinia_zone='europe-west1',
sketch_id=123,
run_all_jobs=False)
self.assertEqual(turbinia_processor.disk_name, 'disk-1')
self.assertEqual(turbinia_processor.project, 'turbinia-project')
self.assertEqual(turbinia_processor.turbinia_zone, 'europe-west1')
self.assertEqual(turbinia_processor.sketch_id, 123)
self.assertEqual(turbinia_processor.run_all_jobs, False)
self.assertEqual(test_state.errors, [])
# TURBINIA_REGION is dynamically generated
# pylint: disable=no-member
self.assertEqual(turbinia_processor.turbinia_region,
turbinia.turbinia_config.TURBINIA_REGION)
# pylint: disable=protected-access
six.assertRegex(self, turbinia_processor._output_path,
'(/tmp/tmp|/var/folders).+')
示例3: test_open_test_case
# 需要导入模块: import six [as 别名]
# 或者: from six import assertRegex [as 别名]
def test_open_test_case(self):
"""
Given: FuzzLoggerCsv with a virtual file handle.
When: Calling open_test_case with some test_case_id.
Then: open_test_case logs as expected.
"""
# When
self.logger.open_test_case(
self.some_test_case_id, name=self.some_test_case_name, index=self.some_test_case_index
)
# Then
self.virtual_file.seek(0)
six.assertRegex(
self,
self.virtual_file.readline(),
LOGGER_PREAMBLE + re.escape("open test case,,,Test case " + self.some_test_case_id + "\r\n"),
)
示例4: test_log_info
# 需要导入模块: import six [as 别名]
# 或者: from six import assertRegex [as 别名]
def test_log_info(self):
"""
Given: FuzzLoggerCsv with a virtual file handle.
When: Calling open_test_case with some test_case_id.
and: Calling log_info with some description.
Then: open_test_case logs as expected.
and: log_info logs as expected.
"""
# When
self.logger.open_test_case(
self.some_test_case_id, name=self.some_test_case_name, index=self.some_test_case_index
)
self.logger.log_info(self.some_log_info_msg)
# Then
self.virtual_file.seek(0)
six.assertRegex(
self,
self.virtual_file.readline(),
LOGGER_PREAMBLE + re.escape("open test case,,,Test case " + self.some_test_case_id + "\r\n"),
)
six.assertRegex(
self, self.virtual_file.readline(), LOGGER_PREAMBLE + re.escape("info,,," + self.some_log_info_msg + "\r\n")
)
示例5: test_log_fail
# 需要导入模块: import six [as 别名]
# 或者: from six import assertRegex [as 别名]
def test_log_fail(self):
"""
Given: FuzzLoggerCsv with a virtual file handle.
When: Calling open_test_case with some test_case_id.
and: Calling log_fail with some description.
Then: open_test_case logs as expected.
and: log_fail logs as expected.
"""
# When
self.logger.open_test_case(
self.some_test_case_id, name=self.some_test_case_name, index=self.some_test_case_index
)
self.logger.log_fail(self.some_log_fail_msg)
# Then
self.virtual_file.seek(0)
six.assertRegex(
self,
self.virtual_file.readline(),
LOGGER_PREAMBLE + re.escape("open test case,,,Test case " + self.some_test_case_id + "\r\n"),
)
six.assertRegex(
self, self.virtual_file.readline(), LOGGER_PREAMBLE + re.escape("fail,,," + self.some_log_fail_msg + "\r\n")
)
示例6: test_log_pass
# 需要导入模块: import six [as 别名]
# 或者: from six import assertRegex [as 别名]
def test_log_pass(self):
"""
Given: FuzzLoggerCsv with a virtual file handle.
When: Calling open_test_case with some test_case_id.
and: Calling log_pass with some description.
Then: open_test_case logs as expected.
and: log_pass logs as expected.
"""
# When
self.logger.open_test_case(
self.some_test_case_id, name=self.some_test_case_name, index=self.some_test_case_index
)
self.logger.log_pass(self.some_log_pass_msg)
# Then
self.virtual_file.seek(0)
six.assertRegex(
self,
self.virtual_file.readline(),
LOGGER_PREAMBLE + re.escape("open test case,,,Test case " + self.some_test_case_id + "\r\n"),
)
six.assertRegex(
self, self.virtual_file.readline(), LOGGER_PREAMBLE + re.escape("pass,,," + self.some_log_pass_msg + "\r\n")
)
示例7: test_open_test_step_empty
# 需要导入模块: import six [as 别名]
# 或者: from six import assertRegex [as 别名]
def test_open_test_step_empty(self):
"""
Given: FuzzLoggerCsv with a virtual file handle.
When: Calling open_test_case with some test_case_id.
and: Calling open_test_step with an empty string.
Then: open_test_step logs with a zero-length description.
"""
# When
self.logger.open_test_case(
self.some_test_case_id, name=self.some_test_case_name, index=self.some_test_case_index
)
self.logger.open_test_step("")
# Then
self.virtual_file.seek(0)
six.assertRegex(
self,
self.virtual_file.readline(),
LOGGER_PREAMBLE + re.escape("open test case,,,Test case " + self.some_test_case_id + "\r\n"),
)
six.assertRegex(self, self.virtual_file.readline(), LOGGER_PREAMBLE + re.escape("open step,,,\r\n"))
示例8: test_log_check_empty
# 需要导入模块: import six [as 别名]
# 或者: from six import assertRegex [as 别名]
def test_log_check_empty(self):
"""
Given: FuzzLoggerCsv with a virtual file handle.
When: Calling open_test_case with some test_case_id.
and: Calling log_check with an empty string.
Then: log_check logs with a zero-length description.
"""
# When
self.logger.open_test_case(
self.some_test_case_id, name=self.some_test_case_name, index=self.some_test_case_index
)
self.logger.log_check("")
# Then
self.virtual_file.seek(0)
six.assertRegex(
self,
self.virtual_file.readline(),
LOGGER_PREAMBLE + re.escape("open test case,,,Test case " + self.some_test_case_id + "\r\n"),
)
six.assertRegex(self, self.virtual_file.readline(), LOGGER_PREAMBLE + re.escape("check,,,\r\n"))
示例9: test_log_error_empty
# 需要导入模块: import six [as 别名]
# 或者: from six import assertRegex [as 别名]
def test_log_error_empty(self):
"""
Given: FuzzLoggerCsv with a virtual file handle.
When: Calling open_test_case with some test_case_id.
and: Calling log_error with an empty string.
Then: log_error logs with a zero-length description.
"""
# When
self.logger.open_test_case(
self.some_test_case_id, name=self.some_test_case_name, index=self.some_test_case_index
)
self.logger.log_error("")
# Then
self.virtual_file.seek(0)
six.assertRegex(
self,
self.virtual_file.readline(),
LOGGER_PREAMBLE + re.escape("open test case,,,Test case " + self.some_test_case_id + "\r\n"),
)
six.assertRegex(self, self.virtual_file.readline(), LOGGER_PREAMBLE + re.escape("error,,,\r\n"))
示例10: test_log_fail_empty
# 需要导入模块: import six [as 别名]
# 或者: from six import assertRegex [as 别名]
def test_log_fail_empty(self):
"""
Given: FuzzLoggerCsv with a virtual file handle.
When: Calling open_test_case with some test_case_id.
and: Calling log_fail with no argument.
Then: log_fail logs with a zero-length description.
"""
# When
self.logger.open_test_case(
self.some_test_case_id, name=self.some_test_case_name, index=self.some_test_case_index
)
self.logger.log_fail("")
# Then
self.virtual_file.seek(0)
six.assertRegex(
self,
self.virtual_file.readline(),
LOGGER_PREAMBLE + re.escape("open test case,,,Test case " + self.some_test_case_id + "\r\n"),
)
six.assertRegex(self, self.virtual_file.readline(), LOGGER_PREAMBLE + re.escape("fail,,,\r\n"))
示例11: test_log_pass_empty
# 需要导入模块: import six [as 别名]
# 或者: from six import assertRegex [as 别名]
def test_log_pass_empty(self):
"""
Given: FuzzLoggerCsv with a virtual file handle.
When: Calling open_test_case with some test_case_id.
and: Calling log_pass with no argument.
Then: log_pass logs with a zero-length description.
"""
# When
self.logger.open_test_case(
self.some_test_case_id, name=self.some_test_case_name, index=self.some_test_case_index
)
self.logger.log_pass("")
# Then
self.virtual_file.seek(0)
six.assertRegex(
self,
self.virtual_file.readline(),
LOGGER_PREAMBLE + re.escape("open test case,,,Test case " + self.some_test_case_id + "\r\n"),
)
six.assertRegex(self, self.virtual_file.readline(), LOGGER_PREAMBLE + re.escape("pass,,,\r\n"))
示例12: assertQuickReplyLinks
# 需要导入模块: import six [as 别名]
# 或者: from six import assertRegex [as 别名]
def assertQuickReplyLinks(self, output):
"""Assert reply links created by setup_quick_replies are present."""
link = r'data-qr="%s">\s*%s\s*</a>'
six.assertRegex(
self, output.get_data(as_text=True), link % (self.r1, self.sr1)
)
six.assertRegex(
self, output.get_data(as_text=True), link % (self.r2, self.sr2)
)
示例13: test_print_report
# 需要导入模块: import six [as 别名]
# 或者: from six import assertRegex [as 别名]
def test_print_report(self):
x = self.x
self.f.apply((chainer.Variable(x),))
self.f.apply((chainer.Variable(x),))
io = six.StringIO()
self.h.print_report(unit=self.unit, file=io)
expect = r'''\AFunctionName +ElapsedTime +Occurrence
+Exp +[0-9.\-e]+(.s|sec) +[0-9]+
\Z'''
actual = io.getvalue()
six.assertRegex(self, actual, expect)
示例14: test_print_report
# 需要导入模块: import six [as 别名]
# 或者: from six import assertRegex [as 别名]
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)
示例15: testInvalidBasicType
# 需要导入模块: import six [as 别名]
# 或者: from six import assertRegex [as 别名]
def testInvalidBasicType(self):
with self.assertRaises(SyntaxError) as assert_raises:
self._parse_config("""
scope/some_fn.arg1 = None
scope/some_fn.arg2 = Garbage # <-- Not a valid Python value.
""")
self.assertEqual(assert_raises.exception.lineno, 3)
self.assertEqual(assert_raises.exception.offset, 29)
self.assertEqual(
assert_raises.exception.text.strip(),
'scope/some_fn.arg2 = Garbage # <-- Not a valid Python value.')
six.assertRegex(self, str(assert_raises.exception),
r"malformed (string|node or string: <_ast.Name [^\n]+>)\n"
r" Failed to parse token 'Garbage' \(line 3\)")