本文整理汇总了Python中unittest.TestCase.assertRegex方法的典型用法代码示例。如果您正苦于以下问题:Python TestCase.assertRegex方法的具体用法?Python TestCase.assertRegex怎么用?Python TestCase.assertRegex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.TestCase
的用法示例。
在下文中一共展示了TestCase.assertRegex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_valid_key
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertRegex [as 别名]
def get_valid_key(test: unittest.TestCase, app: App=None) -> str:
"""
Produce a valid key by using the arobito default credentials against the :py:meth:`App.auth
<arobito.controlinterface.ControllerBackend.App.auth>` method
:param test: The currently running unit test case
:return: A valid key
"""
if app is None:
app = create_app(test)
request_valid = dict(username='arobito', password='arobito')
response = app.auth(request_valid)
test.assertIsNotNone(response, 'Response is none')
test.assertIsInstance(response, dict, 'Response is not a dict')
test.assertIn('auth', response, 'Response does not contain an auth element')
auth = response['auth']
test.assertIn('key', auth, 'Auth object does not contain a key')
key = auth['key']
test.assertIsNotNone(key, 'Key is None')
test.assertIsInstance(key, str, 'Key is not a String')
test.assertRegex(key, '^[a-zA-Z0-9]{64}$', 'Key looks not like expected')
return key