diff --git a/keystone/tests/unit/core.py b/keystone/tests/unit/core.py index 582357af28..70374d4162 100644 --- a/keystone/tests/unit/core.py +++ b/keystone/tests/unit/core.py @@ -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. diff --git a/keystone/tests/unit/test_middleware.py b/keystone/tests/unit/test_middleware.py index 3178b0ae7b..736c85f969 100644 --- a/keystone/tests/unit/test_middleware.py +++ b/keystone/tests/unit/test_middleware.py @@ -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')