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

View File

@ -1532,8 +1532,8 @@ class TestCinderRtstoolCmd(test.TestCase):
regexp = (r'targetcli not installed and could not create default '
r'directory \(dirname\): error$')
self.assertRaisesRegexp(cinder_rtstool.RtstoolError, regexp,
cinder_rtstool.save_to_file, None)
self.assertRaisesRegex(cinder_rtstool.RtstoolError, regexp,
cinder_rtstool.save_to_file, None)
@mock.patch.object(cinder_rtstool, 'os', autospec=True)
@mock.patch.object(cinder_rtstool, 'rtslib_fb', autospec=True)
@ -1541,8 +1541,8 @@ 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,
cinder_rtstool.save_to_file, 'myfile')
self.assertRaisesRegex(cinder_rtstool.RtstoolError, regexp,
cinder_rtstool.save_to_file, 'myfile')
@mock.patch.object(cinder_rtstool, 'rtslib_fb',
**{'root.default_save_file': mock.sentinel.filename})

View File

@ -781,13 +781,13 @@ class CommonAdapterTest(test.TestCase):
self.assertEqual(['spa_eth2'], normalized.unity_io_ports)
def test_normalize_config_raise(self):
with self.assertRaisesRegexp(exception.InvalidConfigurationValue,
'unity_storage_pool_names'):
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,
'unity_io_ports'):
with self.assertRaisesRegex(exception.InvalidConfigurationValue,
'unity_io_ports'):
config = MockConfig()
config.unity_io_ports = ['', ' ']
self.adapter.normalize_config(config)
@ -932,13 +932,13 @@ 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,
'unity_io_ports'):
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,
'unity_io_ports'):
with self.assertRaisesRegex(exception.InvalidConfigurationValue,
'unity_io_ports'):
self.adapter.validate_ports(['spa_iom*', 'spc_invalid'])

View File

@ -186,9 +186,9 @@ class TestClient(test.TestCase):
@res_mock.patch_client
def test_delete_lun_exception(self, client, mocked):
self.assertRaisesRegexp(storops_ex.VNXDeleteLunError,
'General lun delete error.',
client.delete_lun, mocked['lun'].name)
self.assertRaisesRegex(storops_ex.VNXDeleteLunError,
'General lun delete error.',
client.delete_lun, mocked['lun'].name)
@res_mock.patch_client
def test_cleanup_async_lun(self, client, mocked):
@ -374,12 +374,12 @@ 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,
'No HLU available.',
client.add_lun_to_sg,
mocked['sg'],
mocked['lun'],
3)
self.assertRaisesRegex(storops_ex.VNXNoHluAvailableError,
'No HLU available.',
client.add_lun_to_sg,
mocked['sg'],
mocked['lun'],
3)
@res_mock.patch_client
def test_update_consistencygroup_no_lun_in_cg(self, client, mocked):

View File

@ -451,8 +451,8 @@ 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,
'No available pools found.'):
with self.assertRaisesRegex(exception.VolumeBackendAPIException,
'No available pools found.'):
pool = self._select_leastused_poolnumber(self.vol,
self.pools,
self.xml)
@ -476,8 +476,8 @@ 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,
'No available pools found.'):
with self.assertRaisesRegex(exception.VolumeBackendAPIException,
'No available pools found.'):
pool = self._select_migrate_poolnumber(self.vol,
self.pools,
self.xml,
@ -496,8 +496,8 @@ 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,
'No available pools found.'):
with self.assertRaisesRegex(exception.VolumeBackendAPIException,
'No available pools found.'):
pool = self._select_dsv_poolnumber(self.vol, self.pools)
self.pools[2]['free'] = savePool2
self.pools[3]['free'] = savePool3
@ -519,8 +519,8 @@ 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,
'No available pools found.'):
with self.assertRaisesRegex(exception.VolumeBackendAPIException,
'No available pools found.'):
pool = self._select_ddr_poolnumber(self.vol,
self.pools,
self.xml,
@ -529,8 +529,8 @@ class NominatePoolLDTest(volume_helper.MStorageDSVDriver, test.TestCase):
self.pools[3]['free'] = savePool3
self.vol.size = 999999999999
with self.assertRaisesRegexp(exception.VolumeBackendAPIException,
'No available pools found.'):
with self.assertRaisesRegex(exception.VolumeBackendAPIException,
'No available pools found.'):
pool = self._select_ddr_poolnumber(self.vol,
self.pools,
self.xml,
@ -548,8 +548,8 @@ 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,
'No available pools found.'):
with self.assertRaisesRegex(exception.VolumeBackendAPIException,
'No available pools found.'):
pool = self._select_volddr_poolnumber(self.vol,
self.pools,
self.xml,
@ -558,8 +558,8 @@ class NominatePoolLDTest(volume_helper.MStorageDSVDriver, test.TestCase):
self.pools[1]['free'] = savePool1
self.vol.size = 999999999999
with self.assertRaisesRegexp(exception.VolumeBackendAPIException,
'No available pools found.'):
with self.assertRaisesRegex(exception.VolumeBackendAPIException,
'No available pools found.'):
pool = self._select_volddr_poolnumber(self.vol,
self.pools,
self.xml,
@ -588,10 +588,10 @@ 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,
'Logical Disk Set'
' `LX:OpenStackX`'
' could not be found.'):
with self.assertRaisesRegex(exception.NotFound,
'Logical Disk Set'
' `LX:OpenStackX`'
' could not be found.'):
self.get_ldset(self.ldsets)
@ -613,17 +613,17 @@ class VolumeCreateTest(volume_helper.MStorageDSVDriver, test.TestCase):
self._validate_migrate_volume(self.vol, self.xml)
self.vol.status = 'creating'
with self.assertRaisesRegexp(exception.VolumeBackendAPIException,
'Specified Logical Disk'
' LX:287RbQoP7VdwR1WsPC2fZT'
' is not available.'):
with self.assertRaisesRegex(exception.VolumeBackendAPIException,
'Specified Logical Disk'
' LX:287RbQoP7VdwR1WsPC2fZT'
' is not available.'):
self._validate_migrate_volume(self.vol, self.xml)
self.vol.id = "AAAAAAAA"
self.vol.status = 'available'
with self.assertRaisesRegexp(exception.NotFound,
'Logical Disk `LX:37mA82`'
' could not be found.'):
with self.assertRaisesRegex(exception.NotFound,
'Logical Disk `LX:37mA82`'
' could not be found.'):
self._validate_migrate_volume(self.vol, self.xml)
def test_extend_volume(self):
@ -631,9 +631,9 @@ 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,
'RPL Attribute Error. '
'RPL Attribute = RV.'):
with self.assertRaisesRegex(exception.VolumeBackendAPIException,
'RPL Attribute Error. '
'RPL Attribute = RV.'):
self.extend_volume(self.vol, 10)
@ -789,9 +789,9 @@ 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,
r'Failed to unregister Logical Disk from'
r' Logical Disk Set \(iSM31064\)'):
with self.assertRaisesRegex(exception.VolumeBackendAPIException,
r'Failed to unregister Logical Disk from'
r' Logical Disk Set \(iSM31064\)'):
self.mock_object(self._cli, 'delldsetld',
return_value=(False, 'iSM31064'))
self._iscsi_terminate_connection(self.vol, connector)
@ -828,9 +828,9 @@ class ExportTest(volume_helper.MStorageDSVDriver, test.TestCase):
self.assertEqual(
'2A00000991020012',
info['data']['initiator_target_map']['10000090FAA0786B'][3])
with self.assertRaisesRegexp(exception.VolumeBackendAPIException,
r'Failed to unregister Logical Disk from'
r' Logical Disk Set \(iSM31064\)'):
with self.assertRaisesRegex(exception.VolumeBackendAPIException,
r'Failed to unregister Logical Disk from'
r' Logical Disk Set \(iSM31064\)'):
self.mock_object(self._cli, 'delldsetld',
return_value=(False, 'iSM31064'))
self._fc_terminate_connection(self.vol, connector)
@ -937,9 +937,9 @@ 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,
'Logical Disk `LX:XXXXXXXX`'
' could not be found.'):
with self.assertRaisesRegex(exception.NotFound,
'Logical Disk `LX:XXXXXXXX`'
' could not be found.'):
self._validate_ld_exist(
self.lds, self.vol.id, self._properties['ld_name_format'])

View File

@ -86,8 +86,8 @@ 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,
exc_regex) as exc:
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,8 +182,8 @@ 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.library._check_storage_system)
self.assertRaisesRegex(exception.NetAppDriverException, exc_str,
self.library._check_storage_system)
info_log.assert_called_once_with(mock.ANY, controller_ips)
@ -212,9 +212,9 @@ 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,
'bad.*?status',
self.library._check_storage_system)
self.assertRaisesRegex(exception.NetAppDriverException,
'bad.*?status',
self.library._check_storage_system)
@mock.patch('oslo_service.loopingcall.FixedIntervalLoopingCall', new=
cinder_utils.ZeroIntervalLoopingCall)
@ -1885,10 +1885,10 @@ class NetAppEseriesLibraryMultiAttachTestCase(test.TestCase):
return_value=fake_label)
fake_snapshot = copy.deepcopy(eseries_fake.FAKE_CINDER_SNAPSHOT)
self.assertRaisesRegexp(exception.NetAppDriverException,
exc_msg,
self.library.create_snapshot,
fake_snapshot)
self.assertRaisesRegex(exception.NetAppDriverException,
exc_msg,
self.library.create_snapshot,
fake_snapshot)
self.assertTrue(delete_snap_grp.called)
def test_create_snapshot_no_snap_group(self):
@ -1941,10 +1941,10 @@ class NetAppEseriesLibraryMultiAttachTestCase(test.TestCase):
# Error message should contain the maximum number of supported
# snapshots
self.assertRaisesRegexp(exception.SnapshotLimitExceeded,
str(self.library.MAX_SNAPSHOT_COUNT *
grp_count),
self.library.create_snapshot, fake_snapshot)
self.assertRaisesRegex(exception.SnapshotLimitExceeded,
str(self.library.MAX_SNAPSHOT_COUNT *
grp_count),
self.library.create_snapshot, fake_snapshot)
def test_delete_snapshot(self):
fake_vol = cinder_utils.create_volume(self.ctxt)