Merge "trivial: Replace assertRaisesRegexp with assertRaisesRegex"

This commit is contained in:
Zuul 2022-03-24 00:28:36 +00:00 committed by Gerrit Code Review
commit 7ec2036db9
5 changed files with 12 additions and 8 deletions

View File

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

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

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