Remove assertRaisesRegexp testing function
This change removes the function assertRaisesRegexp from within keystone to help reduce any confusion about what is really being called within the appropriate test. The test was changed to use assertRaisesRegex() which is aliased in six for python 2 and 3. assertRaisesRegexp in this change was a part of keystone itself rather than the function of the same name from python 2, and was causing confusion with recent changed regarding deprecation and python 3 changing the name to assertRaisesRegex. Change-Id: I63c84ff432e08866253cfb14ad3bb8db4a665589
This commit is contained in:
parent
7754f170aa
commit
cdee7e6ebf
@ -21,7 +21,6 @@ import hashlib
|
||||
import json
|
||||
import ldap
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import socket
|
||||
import sys
|
||||
@ -797,32 +796,6 @@ class TestCase(BaseTestCase):
|
||||
def assertNotEmpty(self, l):
|
||||
self.assertGreater(len(l), 0)
|
||||
|
||||
def assertRaisesRegexp(self, expected_exception, expected_regexp,
|
||||
callable_obj, *args, **kwargs):
|
||||
"""Assert that the message in a raised exception matches a regexp."""
|
||||
try:
|
||||
callable_obj(*args, **kwargs)
|
||||
except expected_exception as exc_value:
|
||||
if isinstance(expected_regexp, six.string_types):
|
||||
expected_regexp = re.compile(expected_regexp)
|
||||
|
||||
if isinstance(exc_value.args[0], six.text_type):
|
||||
if not expected_regexp.search(six.text_type(exc_value)):
|
||||
raise self.failureException(
|
||||
'"%s" does not match "%s"' %
|
||||
(expected_regexp.pattern, six.text_type(exc_value)))
|
||||
else:
|
||||
if not expected_regexp.search(str(exc_value)):
|
||||
raise self.failureException(
|
||||
'"%s" does not match "%s"' %
|
||||
(expected_regexp.pattern, str(exc_value)))
|
||||
else:
|
||||
if hasattr(expected_exception, '__name__'):
|
||||
excName = expected_exception.__name__
|
||||
else:
|
||||
excName = str(expected_exception)
|
||||
raise self.failureException("%s not raised" % excName)
|
||||
|
||||
def assertUserDictEqual(self, expected, observed, message=''):
|
||||
"""Assert that a user dict is equal to another user dict.
|
||||
|
||||
|
@ -713,9 +713,9 @@ class AuthContextMiddlewareTest(test_backend_sql.SqlTests,
|
||||
'request environment.' %
|
||||
CONF.tokenless_auth.issuer_attribute)
|
||||
# Check the content of the exception message as well
|
||||
self.assertRaisesRegexp(exception.TokenlessAuthConfigError,
|
||||
expected_msg,
|
||||
auth._build_idp_id)
|
||||
self.assertRaisesRegex(exception.TokenlessAuthConfigError,
|
||||
expected_msg,
|
||||
auth._build_idp_id)
|
||||
|
||||
def test_admin_token_context(self):
|
||||
self.config_fixture.config(admin_token='ADMIN')
|
||||
|
Loading…
Reference in New Issue
Block a user