Merge "Replace assertRaisesRegexp with assertRaisesRegex"

This commit is contained in:
Zuul 2018-08-31 19:20:38 +00:00 committed by Gerrit Code Review
commit 45df029a4d
7 changed files with 93 additions and 93 deletions

View File

@ -105,7 +105,7 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
"description": "",
"add_volumes": None,
"remove_volumes": None, }}
self.assertRaisesRegexp(webob.exc.HTTPBadRequest,
self.assertRaisesRegex(webob.exc.HTTPBadRequest,
"Name, description, add_volumes, "
"and remove_volumes can not be all "
"empty in the request body.",
@ -128,7 +128,7 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
"description": None,
"add_volumes": None,
"remove_volumes": None, }}
self.assertRaisesRegexp(webob.exc.HTTPBadRequest, "Must specify "
self.assertRaisesRegex(webob.exc.HTTPBadRequest, "Must specify "
"one or more of the following keys to "
"update: name, description, add_volumes, "
"remove_volumes.", self.controller.update,
@ -153,7 +153,7 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
"description": None,
"add_volumes": None,
"remove_volumes": None, }}
self.assertRaisesRegexp(webob.exc.HTTPBadRequest, "Name, description, "
self.assertRaisesRegex(webob.exc.HTTPBadRequest, "Name, description, "
"add_volumes, and remove_volumes can not be "
"all empty in the request body.",
self.controller.update,
@ -175,7 +175,7 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
req.headers['Content-Type'] = 'application/json'
body = None
self.assertRaisesRegexp(webob.exc.HTTPBadRequest,
self.assertRaisesRegex(webob.exc.HTTPBadRequest,
"Missing request body",
self.controller.update,
req, consistencygroup.id, body)

View File

@ -1532,7 +1532,7 @@ class TestCinderRtstoolCmd(test.TestCase):
regexp = (r'targetcli not installed and could not create default '
r'directory \(dirname\): error$')
self.assertRaisesRegexp(cinder_rtstool.RtstoolError, regexp,
self.assertRaisesRegex(cinder_rtstool.RtstoolError, regexp,
cinder_rtstool.save_to_file, None)
@mock.patch.object(cinder_rtstool, 'os', autospec=True)
@ -1541,7 +1541,7 @@ class TestCinderRtstoolCmd(test.TestCase):
save = mock_rtslib.root.RTSRoot.return_value.save_to_file
save.side_effect = OSError('error')
regexp = r'Could not save configuration to myfile: error'
self.assertRaisesRegexp(cinder_rtstool.RtstoolError, regexp,
self.assertRaisesRegex(cinder_rtstool.RtstoolError, regexp,
cinder_rtstool.save_to_file, 'myfile')
@mock.patch.object(cinder_rtstool, 'rtslib_fb',

View File

@ -781,12 +781,12 @@ class CommonAdapterTest(test.TestCase):
self.assertEqual(['spa_eth2'], normalized.unity_io_ports)
def test_normalize_config_raise(self):
with self.assertRaisesRegexp(exception.InvalidConfigurationValue,
with self.assertRaisesRegex(exception.InvalidConfigurationValue,
'unity_storage_pool_names'):
config = MockConfig()
config.unity_storage_pool_names = ['', ' ']
self.adapter.normalize_config(config)
with self.assertRaisesRegexp(exception.InvalidConfigurationValue,
with self.assertRaisesRegex(exception.InvalidConfigurationValue,
'unity_io_ports'):
config = MockConfig()
config.unity_io_ports = ['', ' ']
@ -932,12 +932,12 @@ class FCAdapterTest(test.TestCase):
self.assertEqual(set(('spa_iom_0_fc0', 'spa_iom_0_fc1')), set(ports))
def test_validate_ports_no_matched(self):
with self.assertRaisesRegexp(exception.InvalidConfigurationValue,
with self.assertRaisesRegex(exception.InvalidConfigurationValue,
'unity_io_ports'):
self.adapter.validate_ports(['spc_invalid'])
def test_validate_ports_unmatched_whitelist(self):
with self.assertRaisesRegexp(exception.InvalidConfigurationValue,
with self.assertRaisesRegex(exception.InvalidConfigurationValue,
'unity_io_ports'):
self.adapter.validate_ports(['spa_iom*', 'spc_invalid'])

View File

@ -186,7 +186,7 @@ class TestClient(test.TestCase):
@res_mock.patch_client
def test_delete_lun_exception(self, client, mocked):
self.assertRaisesRegexp(storops_ex.VNXDeleteLunError,
self.assertRaisesRegex(storops_ex.VNXDeleteLunError,
'General lun delete error.',
client.delete_lun, mocked['lun'].name)
@ -374,7 +374,7 @@ class TestClient(test.TestCase):
@res_mock.patch_client
def test_add_lun_to_sg_alu_in_use(self, client, mocked):
self.assertRaisesRegexp(storops_ex.VNXNoHluAvailableError,
self.assertRaisesRegex(storops_ex.VNXNoHluAvailableError,
'No HLU available.',
client.add_lun_to_sg,
mocked['sg'],

View File

@ -451,7 +451,7 @@ class NominatePoolLDTest(volume_helper.MStorageDSVDriver, test.TestCase):
self.assertEqual(1, pool, "selected pool should be 1")
# config:pool_pools=[1]
self.vol.size = 999999999999
with self.assertRaisesRegexp(exception.VolumeBackendAPIException,
with self.assertRaisesRegex(exception.VolumeBackendAPIException,
'No available pools found.'):
pool = self._select_leastused_poolnumber(self.vol,
self.pools,
@ -476,7 +476,7 @@ class NominatePoolLDTest(volume_helper.MStorageDSVDriver, test.TestCase):
dummyhost)
self.assertEqual(-1, pool, "selected pool is the same pool(return -1)")
self.vol.size = 999999999999
with self.assertRaisesRegexp(exception.VolumeBackendAPIException,
with self.assertRaisesRegex(exception.VolumeBackendAPIException,
'No available pools found.'):
pool = self._select_migrate_poolnumber(self.vol,
self.pools,
@ -496,7 +496,7 @@ class NominatePoolLDTest(volume_helper.MStorageDSVDriver, test.TestCase):
savePool3 = self.pools[3]['free']
self.pools[2]['free'] = 0
self.pools[3]['free'] = 0
with self.assertRaisesRegexp(exception.VolumeBackendAPIException,
with self.assertRaisesRegex(exception.VolumeBackendAPIException,
'No available pools found.'):
pool = self._select_dsv_poolnumber(self.vol, self.pools)
self.pools[2]['free'] = savePool2
@ -519,7 +519,7 @@ class NominatePoolLDTest(volume_helper.MStorageDSVDriver, test.TestCase):
savePool3 = self.pools[3]['free']
self.pools[2]['free'] = 0
self.pools[3]['free'] = 0
with self.assertRaisesRegexp(exception.VolumeBackendAPIException,
with self.assertRaisesRegex(exception.VolumeBackendAPIException,
'No available pools found.'):
pool = self._select_ddr_poolnumber(self.vol,
self.pools,
@ -529,7 +529,7 @@ class NominatePoolLDTest(volume_helper.MStorageDSVDriver, test.TestCase):
self.pools[3]['free'] = savePool3
self.vol.size = 999999999999
with self.assertRaisesRegexp(exception.VolumeBackendAPIException,
with self.assertRaisesRegex(exception.VolumeBackendAPIException,
'No available pools found.'):
pool = self._select_ddr_poolnumber(self.vol,
self.pools,
@ -548,7 +548,7 @@ class NominatePoolLDTest(volume_helper.MStorageDSVDriver, test.TestCase):
savePool1 = self.pools[1]['free']
self.pools[0]['free'] = 0
self.pools[1]['free'] = 0
with self.assertRaisesRegexp(exception.VolumeBackendAPIException,
with self.assertRaisesRegex(exception.VolumeBackendAPIException,
'No available pools found.'):
pool = self._select_volddr_poolnumber(self.vol,
self.pools,
@ -558,7 +558,7 @@ class NominatePoolLDTest(volume_helper.MStorageDSVDriver, test.TestCase):
self.pools[1]['free'] = savePool1
self.vol.size = 999999999999
with self.assertRaisesRegexp(exception.VolumeBackendAPIException,
with self.assertRaisesRegex(exception.VolumeBackendAPIException,
'No available pools found.'):
pool = self._select_volddr_poolnumber(self.vol,
self.pools,
@ -588,7 +588,7 @@ class GetInformationTest(volume_helper.MStorageDSVDriver, test.TestCase):
ldset = self.get_ldset(self.ldsets)
self.assertEqual('LX:OpenStack1', ldset['ldsetname'])
self._properties['ldset_name'] = 'LX:OpenStackX'
with self.assertRaisesRegexp(exception.NotFound,
with self.assertRaisesRegex(exception.NotFound,
'Logical Disk Set'
' `LX:OpenStackX`'
' could not be found.'):
@ -613,7 +613,7 @@ class VolumeCreateTest(volume_helper.MStorageDSVDriver, test.TestCase):
self._validate_migrate_volume(self.vol, self.xml)
self.vol.status = 'creating'
with self.assertRaisesRegexp(exception.VolumeBackendAPIException,
with self.assertRaisesRegex(exception.VolumeBackendAPIException,
'Specified Logical Disk'
' LX:287RbQoP7VdwR1WsPC2fZT'
' is not available.'):
@ -621,7 +621,7 @@ class VolumeCreateTest(volume_helper.MStorageDSVDriver, test.TestCase):
self.vol.id = "AAAAAAAA"
self.vol.status = 'available'
with self.assertRaisesRegexp(exception.NotFound,
with self.assertRaisesRegex(exception.NotFound,
'Logical Disk `LX:37mA82`'
' could not be found.'):
self._validate_migrate_volume(self.vol, self.xml)
@ -631,7 +631,7 @@ class VolumeCreateTest(volume_helper.MStorageDSVDriver, test.TestCase):
self.extend_volume(self.vol, 10)
self.vol.id = "00046058-d38e-7f60-67b7-59ed65e54225" # RV
with self.assertRaisesRegexp(exception.VolumeBackendAPIException,
with self.assertRaisesRegex(exception.VolumeBackendAPIException,
'RPL Attribute Error. '
'RPL Attribute = RV.'):
self.extend_volume(self.vol, 10)
@ -789,7 +789,7 @@ class ExportTest(volume_helper.MStorageDSVDriver, test.TestCase):
def test_iscsi_terminate_connection_negative(self):
connector = {'initiator': "iqn.1994-05.com.redhat:d1d8e8f23255",
'multipath': True}
with self.assertRaisesRegexp(exception.VolumeBackendAPIException,
with self.assertRaisesRegex(exception.VolumeBackendAPIException,
r'Failed to unregister Logical Disk from'
r' Logical Disk Set \(iSM31064\)'):
self.mock_object(self._cli, 'delldsetld',
@ -828,7 +828,7 @@ class ExportTest(volume_helper.MStorageDSVDriver, test.TestCase):
self.assertEqual(
'2A00000991020012',
info['data']['initiator_target_map']['10000090FAA0786B'][3])
with self.assertRaisesRegexp(exception.VolumeBackendAPIException,
with self.assertRaisesRegex(exception.VolumeBackendAPIException,
r'Failed to unregister Logical Disk from'
r' Logical Disk Set \(iSM31064\)'):
self.mock_object(self._cli, 'delldsetld',
@ -937,7 +937,7 @@ class NonDisruptiveBackup_test(volume_helper.MStorageDSVDriver,
self.lds, self.vol.id, self._properties['ld_name_format'])
self.assertEqual('LX:287RbQoP7VdwR1WsPC2fZT', ldname)
self.vol.id = "00000000-0000-0000-0000-6b6d96553b4b"
with self.assertRaisesRegexp(exception.NotFound,
with self.assertRaisesRegex(exception.NotFound,
'Logical Disk `LX:XXXXXXXX`'
' could not be found.'):
self._validate_ld_exist(

View File

@ -86,7 +86,7 @@ class NetAppEseriesClientDriverTestCase(test.TestCase):
fake_resp.status_code = status_code
exc_regex = exc_regex if exc_regex is not None else fake_resp.text
with self.assertRaisesRegexp(es_exception.WebServiceException,
with self.assertRaisesRegex(es_exception.WebServiceException,
exc_regex) as exc:
self.my_client._eval_response(fake_resp)
self.assertEqual(status_code, exc.status_code)

View File

@ -182,7 +182,7 @@ class NetAppEseriesLibraryTestCase(test.TestCase):
side_effect=exception.NetAppDriverException(message=exc_str))
info_log = self.mock_object(library.LOG, 'info')
self.assertRaisesRegexp(exception.NetAppDriverException, exc_str,
self.assertRaisesRegex(exception.NetAppDriverException, exc_str,
self.library._check_storage_system)
info_log.assert_called_once_with(mock.ANY, controller_ips)
@ -212,7 +212,7 @@ class NetAppEseriesLibraryTestCase(test.TestCase):
self.mock_object(self.library._client, 'update_stored_system_password')
self.mock_object(time, 'time', side_effect=range(0, 60, 5))
self.assertRaisesRegexp(exception.NetAppDriverException,
self.assertRaisesRegex(exception.NetAppDriverException,
'bad.*?status',
self.library._check_storage_system)
@ -1885,7 +1885,7 @@ class NetAppEseriesLibraryMultiAttachTestCase(test.TestCase):
return_value=fake_label)
fake_snapshot = copy.deepcopy(eseries_fake.FAKE_CINDER_SNAPSHOT)
self.assertRaisesRegexp(exception.NetAppDriverException,
self.assertRaisesRegex(exception.NetAppDriverException,
exc_msg,
self.library.create_snapshot,
fake_snapshot)
@ -1941,7 +1941,7 @@ class NetAppEseriesLibraryMultiAttachTestCase(test.TestCase):
# Error message should contain the maximum number of supported
# snapshots
self.assertRaisesRegexp(exception.SnapshotLimitExceeded,
self.assertRaisesRegex(exception.SnapshotLimitExceeded,
str(self.library.MAX_SNAPSHOT_COUNT *
grp_count),
self.library.create_snapshot, fake_snapshot)