]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix assertRaisesRegexp deprecation warnings in UT
authorMichal Dulko <michal.dulko@intel.com>
Tue, 2 Jun 2015 16:48:26 +0000 (18:48 +0200)
committerMichal Dulko <michal.dulko@intel.com>
Tue, 2 Jun 2015 16:48:26 +0000 (18:48 +0200)
This commit changes assertRaisesRegexp occurrences to
assertRaisesRegex to fix deprecation warnings.

Change-Id: I22fb6224057716f734a8ac69da72ccdb9b464289
Closes-Bug: 1461171

cinder/tests/unit/test_emc_vnxdirect.py
cinder/tests/unit/test_srb.py

index 8fb7cdf9b17f3c95d4a05e213886f54ae8cbc9d1..e3926861e98d1d94e68df1f9e6fd53442184c633 100644 (file)
@@ -1590,11 +1590,11 @@ Time Remaining:  0 second(s)
                                       "unit_test_pool2|fakeSerial",
                                       'storage_protocol': 'iSCSI'}}
 
-        self.assertRaisesRegexp(exception.VolumeBackendAPIException,
-                                "Migration of LUN 1 has been stopped or"
-                                " faulted.",
-                                self.driver.migrate_volume,
-                                None, self.testData.test_volume, fake_host)
+        self.assertRaisesRegex(exception.VolumeBackendAPIException,
+                               "Migration of LUN 1 has been stopped or"
+                               " faulted.",
+                               self.driver.migrate_volume,
+                               None, self.testData.test_volume, fake_host)
 
         expect_cmd = [mock.call(*self.testData.MIGRATION_CMD(),
                                 retry_disable=True,
@@ -2022,11 +2022,11 @@ Time Remaining:  0 second(s)
         self.driverSetup(commands, results)
         offline_volume = self.testData.test_volume.copy()
         offline_volume.update({'name': volume_name})
-        self.assertRaisesRegexp(exception.VolumeBackendAPIException,
-                                "Volume %s was created in VNX, but in"
-                                " Offline state." % volume_name,
-                                self.driver.create_volume,
-                                offline_volume)
+        self.assertRaisesRegex(exception.VolumeBackendAPIException,
+                               "Volume %s was created in VNX, but in"
+                               " Offline state." % volume_name,
+                               self.driver.create_volume,
+                               offline_volume)
 
     def test_create_volume_snapshot_failed(self):
         commands = [self.testData.SNAP_CREATE_CMD('failed_snapshot')]
@@ -3056,14 +3056,14 @@ Time Remaining:  0 second(s)
                                {'storagetype:provisioning': 'compressed'}]))
     def test_create_consistency_group_failed_with_compression(self):
         self.driverSetup([], [])
-        self.assertRaisesRegexp(exception.VolumeBackendAPIException,
-                                "Failed to create consistency group "
-                                "consistencygroup_id "
-                                "because VNX consistency group cannot "
-                                "accept compressed LUNs as members.",
-                                self.driver.create_consistencygroup,
-                                None,
-                                self.testData.test_cg_with_type)
+        self.assertRaisesRegex(exception.VolumeBackendAPIException,
+                               "Failed to create consistency group "
+                               "consistencygroup_id "
+                               "because VNX consistency group cannot "
+                               "accept compressed LUNs as members.",
+                               self.driver.create_consistencygroup,
+                               None,
+                               self.testData.test_cg_with_type)
 
     def test_delete_consistency_group(self):
         cg_name = self.testData.test_cg['id']
@@ -3483,13 +3483,13 @@ Time Remaining:  0 second(s)
                    FAKE_ERROR_RETURN]
 
         fake_cli = self.driverSetup(commands, results)
-        self.assertRaisesRegexp(exception.VolumeBackendAPIException,
-                                'Migrate volume failed',
-                                self.driver.create_consistencygroup_from_src,
-                                None, new_cg, [vol1_in_new_cg, vol2_in_new_cg],
-                                cgsnapshot=src_cgsnap,
-                                snapshots=[snap1_in_src_cgsnap,
-                                           snap2_in_src_cgsnap])
+        self.assertRaisesRegex(exception.VolumeBackendAPIException,
+                               'Migrate volume failed',
+                               self.driver.create_consistencygroup_from_src,
+                               None, new_cg, [vol1_in_new_cg, vol2_in_new_cg],
+                               cgsnapshot=src_cgsnap,
+                               snapshots=[snap1_in_src_cgsnap,
+                                          snap2_in_src_cgsnap])
 
         expect_cmd = [
             mock.call(*self.testData.LUN_DELETE_CMD(
index 84934b45c77b9c6628115672ba2f4e39f16c4ed0..c8e16cdc2cc4930e06409ddca2f0aba5cbd20155 100644 (file)
@@ -212,8 +212,8 @@ class TestHandleProcessExecutionError(test.TestCase):
                     message='', info_message='', reraise=True):
                 raise processutils.ProcessExecutionError(description='Oops')
 
-        self.assertRaisesRegexp(processutils.ProcessExecutionError,
-                                r'^Oops', f)
+        self.assertRaisesRegex(processutils.ProcessExecutionError,
+                               r'^Oops', f)
 
     def test_reraise_false(self):
         with srb.handle_process_execution_error(
@@ -226,7 +226,7 @@ class TestHandleProcessExecutionError(test.TestCase):
                     message='', info_message='', reraise=RuntimeError('Oops')):
                 raise processutils.ProcessExecutionError
 
-        self.assertRaisesRegexp(RuntimeError, r'^Oops', f)
+        self.assertRaisesRegex(RuntimeError, r'^Oops', f)
 
 
 class SRBDriverTestCase(test.TestCase):