trivial: Replace assertRaisesRegexp with assertRaisesRegex

Change-Id: Ib4549e5b0620729c7a13c06506c68570b1fd0ae7
This commit is contained in:
Tim Burke 2021-07-15 14:30:38 -07:00
parent a5fc6a8211
commit 1e410347f0
5 changed files with 12 additions and 8 deletions

View File

@ -43,6 +43,10 @@ warnings.filterwarnings('ignore', module='cryptography|OpenSSL', message=(
'Support for it is now deprecated in cryptography, '
'and will be removed in a future 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

View File

@ -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)

View File

@ -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})

View File

@ -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', '')

View File

@ -2417,7 +2417,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)