diff --git a/test/__init__.py b/test/__init__.py index 481098062b..cf7347c63f 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -47,6 +47,10 @@ warnings.filterwarnings('ignore', module='cryptography|OpenSSL', message=( 'Support for it is now deprecated in cryptography, ' 'and will be removed in the next release.')) +if sys.version_info < (3, 2): + import unittest + unittest.TestCase.assertRaisesRegex = unittest.TestCase.assertRaisesRegexp + from eventlet.green import socket # make unittests pass on all locale diff --git a/test/unit/account/test_backend.py b/test/unit/account/test_backend.py index 8d6d6a954d..0ae192fd4b 100644 --- a/test/unit/account/test_backend.py +++ b/test/unit/account/test_backend.py @@ -1896,7 +1896,7 @@ class TestAccountBrokerBeforePerPolicyContainerTrack( broker, 'create_policy_stat_table', side_effect=sqlite3.OperationalError('foobar')): with broker.get() as conn: - self.assertRaisesRegexp( + self.assertRaisesRegex( sqlite3.OperationalError, '.*foobar.*', broker._migrate_add_storage_policy_index, conn=conn) diff --git a/test/unit/common/middleware/crypto/test_keymaster.py b/test/unit/common/middleware/crypto/test_keymaster.py index 63a74b6b6f..882f88b550 100644 --- a/test/unit/common/middleware/crypto/test_keymaster.py +++ b/test/unit/common/middleware/crypto/test_keymaster.py @@ -248,7 +248,7 @@ class TestKeymaster(unittest.TestCase): def test_missing_conf_section(self): sample_conf = "[default]\nuser = %s\n" % getuser() with tmpfile(sample_conf) as conf_file: - self.assertRaisesRegexp( + self.assertRaisesRegex( ValueError, 'Unable to find keymaster config section in.*', keymaster.KeyMaster, self.swift, { 'keymaster_config_path': conf_file}) diff --git a/test/unit/common/test_daemon.py b/test/unit/common/test_daemon.py index 78a4ff0563..2f0549abbb 100644 --- a/test/unit/common/test_daemon.py +++ b/test/unit/common/test_daemon.py @@ -176,11 +176,11 @@ class TestRunDaemon(unittest.TestCase): # test missing section sample_conf = "[default]\nuser = %s\n" % getuser() with tmpfile(sample_conf) as conf_file: - self.assertRaisesRegexp(SystemExit, - 'Unable to find my-daemon ' - 'config section in.*', - daemon.run_daemon, MyDaemon, - conf_file, once=True) + self.assertRaisesRegex(SystemExit, + 'Unable to find my-daemon ' + 'config section in.*', + daemon.run_daemon, MyDaemon, + conf_file, once=True) def test_run_daemon_diff_tz(self): old_tz = os.environ.get('TZ', '') diff --git a/test/unit/common/test_utils.py b/test/unit/common/test_utils.py index bb9e31eb35..3f14fdcdda 100644 --- a/test/unit/common/test_utils.py +++ b/test/unit/common/test_utils.py @@ -2449,7 +2449,7 @@ log_name = yarr''' 'foo': 'bar', 'bar': 'baz'} self.assertEqual(result, expected) - self.assertRaisesRegexp( + self.assertRaisesRegex( ValueError, 'Unable to find section3 config section in.*', utils.readconf, temppath, 'section3') os.unlink(temppath)