From 955d9088cba9db373953a934c0e8f7060244a856 Mon Sep 17 00:00:00 2001 From: Kallebe Monteiro Date: Mon, 9 Mar 2015 16:05:36 -0300 Subject: [PATCH] Replace assertEqual(True, *) -> assertTrue(*) Inspired by Dave Chen's change request on keystone about this, I decided to check in cinder code to see if there were many cases. Since unittest provides assertTrue and assertFalse, it is better to use assertTrue(var) instead of assertEqual(True, var) and the same thing applies to assertFalse. I used these commands to search the occurrences: * grep -PRIn "assertEqual\(True" * grep -PRIn "assertEqual\(False" * grep -PRIn "assertEqual\(\w+\s*,\s*True" * grep -PRIn "assertEqual\(\w+\s*,\s*False" Closes-Bug: #1430262 Change-Id: Ie92ce744d68a473b9ecc5214ed322bf2c5f5e000 --- cinder/tests/brick/test_brick_connector.py | 12 +++--- cinder/tests/image/test_glance.py | 4 +- cinder/tests/test_dellscapi.py | 24 +++++------ cinder/tests/test_evaluator.py | 50 ++++++++++------------ cinder/tests/test_glusterfs.py | 6 +-- cinder/tests/test_gpfs.py | 28 ++++++------ cinder/tests/test_hplefthand.py | 6 +-- cinder/tests/test_ibm_flashsystem.py | 16 +++---- cinder/tests/test_ibmnas.py | 4 +- cinder/tests/test_prophetstor_dpl.py | 4 +- cinder/tests/test_smbfs.py | 8 ++-- cinder/tests/test_storpool.py | 2 +- cinder/tests/test_v6000_fcp.py | 4 +- cinder/tests/test_volume.py | 16 +++---- cinder/tests/test_volume_types.py | 12 +++--- 15 files changed, 95 insertions(+), 101 deletions(-) diff --git a/cinder/tests/brick/test_brick_connector.py b/cinder/tests/brick/test_brick_connector.py index 314513c46..7aee1daf7 100644 --- a/cinder/tests/brick/test_brick_connector.py +++ b/cinder/tests/brick/test_brick_connector.py @@ -985,10 +985,10 @@ class HuaweiStorHyperConnectorTestCase(ConnectorTestCase): def test_disconnect_volume(self): """Test the basic disconnect volume case.""" self.connector.connect_volume(self.connection_properties) - self.assertEqual(True, HuaweiStorHyperConnectorTestCase.attached) + self.assertTrue(HuaweiStorHyperConnectorTestCase.attached) self.connector.disconnect_volume(self.connection_properties, self.device_info) - self.assertEqual(False, HuaweiStorHyperConnectorTestCase.attached) + self.assertFalse(HuaweiStorHyperConnectorTestCase.attached) expected_commands = [self.fake_sdscli_file + ' -c attach' ' -v volume-b2911673-863c-4380-a5f2-e1729eecfe3f', @@ -1005,14 +1005,14 @@ class HuaweiStorHyperConnectorTestCase(ConnectorTestCase): def test_is_volume_connected(self): """Test if volume connected to host case.""" self.connector.connect_volume(self.connection_properties) - self.assertEqual(True, HuaweiStorHyperConnectorTestCase.attached) + self.assertTrue(HuaweiStorHyperConnectorTestCase.attached) is_connected = self.connector.is_volume_connected( 'volume-b2911673-863c-4380-a5f2-e1729eecfe3f') self.assertEqual(HuaweiStorHyperConnectorTestCase.attached, is_connected) self.connector.disconnect_volume(self.connection_properties, self.device_info) - self.assertEqual(False, HuaweiStorHyperConnectorTestCase.attached) + self.assertFalse(HuaweiStorHyperConnectorTestCase.attached) is_connected = self.connector.is_volume_connected( 'volume-b2911673-863c-4380-a5f2-e1729eecfe3f') self.assertEqual(HuaweiStorHyperConnectorTestCase.attached, @@ -1056,7 +1056,7 @@ class HuaweiStorHyperConnectorTestCase(ConnectorTestCase): def test_disconnect_volume_fail(self): """Test the fail disconnect volume case.""" self.connector.connect_volume(self.connection_properties) - self.assertEqual(True, HuaweiStorHyperConnectorTestCase.attached) + self.assertTrue(HuaweiStorHyperConnectorTestCase.attached) self.assertRaises(exception.BrickException, self.connector_fail.disconnect_volume, self.connection_properties, @@ -1083,7 +1083,7 @@ class HuaweiStorHyperConnectorTestCase(ConnectorTestCase): def test_disconnect_volume_nocli(self): """Test the fail disconnect volume case.""" self.connector.connect_volume(self.connection_properties) - self.assertEqual(True, HuaweiStorHyperConnectorTestCase.attached) + self.assertTrue(HuaweiStorHyperConnectorTestCase.attached) self.assertRaises(exception.BrickException, self.connector_nocli.disconnect_volume, self.connection_properties, diff --git a/cinder/tests/image/test_glance.py b/cinder/tests/image/test_glance.py index 68b91dc91..f4f9ee150 100644 --- a/cinder/tests/image/test_glance.py +++ b/cinder/tests/image/test_glance.py @@ -634,7 +634,7 @@ class TestGlanceImageServiceClient(test.TestCase): def __init__(inst, version, *args, **kwargs): self.assertEqual('1', version) self.assertEqual("http://fake_host:9292", args[0]) - self.assertEqual(True, kwargs['token']) + self.assertTrue(kwargs['token']) self.assertEqual(60, kwargs['timeout']) self.stubs.Set(glance.glanceclient, 'Client', MyGlanceStubClient) @@ -666,7 +666,7 @@ class TestGlanceImageServiceClient(test.TestCase): def __init__(inst, version, *args, **kwargs): self.assertEqual("1", version) self.assertEqual("http://fake_host:9292", args[0]) - self.assertEqual(True, kwargs['token']) + self.assertTrue(kwargs['token']) self.assertNotIn('timeout', kwargs) self.stubs.Set(glance.glanceclient, 'Client', MyGlanceStubClient) diff --git a/cinder/tests/test_dellscapi.py b/cinder/tests/test_dellscapi.py index e326fe1d0..c167f0573 100644 --- a/cinder/tests/test_dellscapi.py +++ b/cinder/tests/test_dellscapi.py @@ -1663,7 +1663,7 @@ class DellSCSanAPITestCase(test.TestCase): mock_delete.assert_called() mock_find_volume.assert_called_once_with(12345, self.volume_name, None) mock_get_json.assert_called() - self.assertEqual(True, res, 'Expected True') + self.assertTrue(res, 'Expected True') @mock.patch.object(dell_storagecenter_api.HttpClient, 'delete', @@ -1691,7 +1691,7 @@ class DellSCSanAPITestCase(test.TestCase): # Test case where volume to be deleted does not exist res = self.scapi.delete_volume(12345, self.volume_name) - self.assertEqual(True, res, 'Expected True') + self.assertTrue(res, 'Expected True') @mock.patch.object(dell_storagecenter_api.StorageCenterApi, '_create_folder_path', @@ -1739,7 +1739,7 @@ class DellSCSanAPITestCase(test.TestCase): self.IQN, False) mock_post.assert_called() - self.assertEqual(True, res, 'Expected True') + self.assertTrue(res, 'Expected True') @mock.patch.object(dell_storagecenter_api.HttpClient, 'post', @@ -1753,7 +1753,7 @@ class DellSCSanAPITestCase(test.TestCase): self.WWN, True) mock_post.assert_called() - self.assertEqual(True, res, 'Expected True') + self.assertTrue(res, 'Expected True') @mock.patch.object(dell_storagecenter_api.HttpClient, 'post', @@ -1767,7 +1767,7 @@ class DellSCSanAPITestCase(test.TestCase): self.IQN, False) mock_post.assert_called() - self.assertEqual(False, res, 'Expected False') + self.assertFalse(res, 'Expected False') @mock.patch.object(dell_storagecenter_api.StorageCenterApi, '_get_json', @@ -2736,7 +2736,7 @@ class DellSCSanAPITestCase(test.TestCase): mock_get.assert_called() mock_get_json.assert_called() mock_delete.assert_called() - self.assertEqual(True, res, 'Expected True') + self.assertTrue(res, 'Expected True') @mock.patch.object(dell_storagecenter_api.HttpClient, 'get', @@ -2749,7 +2749,7 @@ class DellSCSanAPITestCase(test.TestCase): res = self.scapi.unmap_volume(self.VOLUME, self.SCSERVER) mock_get.assert_called() - self.assertEqual(False, res, 'Expected False') + self.assertFalse(res, 'Expected False') @mock.patch.object(dell_storagecenter_api.HttpClient, 'delete', @@ -2772,7 +2772,7 @@ class DellSCSanAPITestCase(test.TestCase): mock_get.assert_called() mock_get_json.assert_called() mock_delete.assert_called() - self.assertEqual(True, res, 'Expected True') + self.assertTrue(res, 'Expected True') @mock.patch.object(dell_storagecenter_api.HttpClient, 'delete', @@ -2795,7 +2795,7 @@ class DellSCSanAPITestCase(test.TestCase): mock_get.assert_called() mock_get_json.assert_called() mock_delete.assert_called() - self.assertEqual(False, res, 'Expected False') + self.assertFalse(res, 'Expected False') @mock.patch.object(dell_storagecenter_api.StorageCenterApi, '_get_json', @@ -2999,7 +2999,7 @@ class DellSCSanAPITestCase(test.TestCase): replayId) mock_post.assert_called() mock_find_replay.assert_called_once_with(self.VOLUME, replayId) - self.assertEqual(True, res, 'Expected True') + self.assertTrue(res, 'Expected True') @mock.patch.object(dell_storagecenter_api.StorageCenterApi, 'find_replay', @@ -3019,7 +3019,7 @@ class DellSCSanAPITestCase(test.TestCase): replayId) mock_post.assert_called() mock_find_replay.assert_called_once_with(self.VOLUME, replayId) - self.assertEqual(True, res, 'Expected True') + self.assertTrue(res, 'Expected True') @mock.patch.object(dell_storagecenter_api.StorageCenterApi, 'find_replay', @@ -3039,7 +3039,7 @@ class DellSCSanAPITestCase(test.TestCase): replayId) mock_post.assert_called() mock_find_replay.assert_called_once_with(self.VOLUME, replayId) - self.assertEqual(False, res, 'Expected False') + self.assertFalse(res, 'Expected False') @mock.patch.object(dell_storagecenter_api.StorageCenterApi, '_first_result', diff --git a/cinder/tests/test_evaluator.py b/cinder/tests/test_evaluator.py index 8bd8ae62d..4ff3384ee 100644 --- a/cinder/tests/test_evaluator.py +++ b/cinder/tests/test_evaluator.py @@ -66,35 +66,31 @@ class EvaluatorTestCase(test.TestCase): -8.0, evaluator. evaluate("((1.0 / 0.5) * (2)) *(-2)")) def test_comparisons(self): - self.assertEqual(True, evaluator.evaluate("1 < 2")) - self.assertEqual(True, evaluator.evaluate("2 > 1")) - self.assertEqual(True, evaluator.evaluate("2 != 1")) - self.assertEqual(False, evaluator.evaluate("1 > 2")) - self.assertEqual(False, evaluator.evaluate("2 < 1")) - self.assertEqual(False, evaluator.evaluate("2 == 1")) - self.assertEqual(True, evaluator.evaluate("(1 == 1) == !(1 == 2)")) + self.assertTrue(evaluator.evaluate("1 < 2")) + self.assertTrue(evaluator.evaluate("2 > 1")) + self.assertTrue(evaluator.evaluate("2 != 1")) + self.assertFalse(evaluator.evaluate("1 > 2")) + self.assertFalse(evaluator.evaluate("2 < 1")) + self.assertFalse(evaluator.evaluate("2 == 1")) + self.assertTrue(evaluator.evaluate("(1 == 1) == !(1 == 2)")) def test_logic_ops(self): - self.assertEqual(True, evaluator.evaluate("(1 == 1) AND (2 == 2)")) - self.assertEqual(True, evaluator.evaluate("(1 == 1) and (2 == 2)")) - self.assertEqual(True, evaluator.evaluate("(1 == 1) && (2 == 2)")) - self.assertEqual(False, evaluator.evaluate("(1 == 1) && (5 == 2)")) - - self.assertEqual(True, evaluator.evaluate("(1 == 1) OR (5 == 2)")) - self.assertEqual(True, evaluator.evaluate("(1 == 1) or (5 == 2)")) - self.assertEqual(True, evaluator.evaluate("(1 == 1) || (5 == 2)")) - self.assertEqual(False, evaluator.evaluate("(5 == 1) || (5 == 2)")) - - self.assertEqual( - False, evaluator.evaluate("(1 == 1) AND NOT (2 == 2)")) - self.assertEqual( - False, evaluator.evaluate("(1 == 1) AND not (2 == 2)")) - self.assertEqual( - False, evaluator.evaluate("(1 == 1) AND !(2 == 2)")) - self.assertEqual( - True, evaluator.evaluate("(1 == 1) AND NOT (5 == 2)")) - self.assertEqual( - True, evaluator.evaluate("(1 == 1) OR NOT (2 == 2) AND (5 == 5)")) + self.assertTrue(evaluator.evaluate("(1 == 1) AND (2 == 2)")) + self.assertTrue(evaluator.evaluate("(1 == 1) and (2 == 2)")) + self.assertTrue(evaluator.evaluate("(1 == 1) && (2 == 2)")) + self.assertFalse(evaluator.evaluate("(1 == 1) && (5 == 2)")) + + self.assertTrue(evaluator.evaluate("(1 == 1) OR (5 == 2)")) + self.assertTrue(evaluator.evaluate("(1 == 1) or (5 == 2)")) + self.assertTrue(evaluator.evaluate("(1 == 1) || (5 == 2)")) + self.assertFalse(evaluator.evaluate("(5 == 1) || (5 == 2)")) + + self.assertFalse(evaluator.evaluate("(1 == 1) AND NOT (2 == 2)")) + self.assertFalse(evaluator.evaluate("(1 == 1) AND not (2 == 2)")) + self.assertFalse(evaluator.evaluate("(1 == 1) AND !(2 == 2)")) + self.assertTrue(evaluator.evaluate("(1 == 1) AND NOT (5 == 2)")) + self.assertTrue(evaluator.evaluate("(1 == 1) OR NOT (2 == 2) " + "AND (5 == 5)")) def test_ternary_conditional(self): self.assertEqual(5, evaluator.evaluate("(1 < 2) ? 5 : 10")) diff --git a/cinder/tests/test_glusterfs.py b/cinder/tests/test_glusterfs.py index 0f9db292f..b85da1250 100644 --- a/cinder/tests/test_glusterfs.py +++ b/cinder/tests/test_glusterfs.py @@ -763,8 +763,7 @@ class GlusterFsDriverTestCase(test.TestCase): cmd = ['umount', test_hashpath] self.assertEqual(cmd[0], mock_execute.call_args[0][0]) self.assertEqual(cmd[1], mock_execute.call_args[0][1]) - self.assertEqual(True, - mock_execute.call_args[1]['run_as_root']) + self.assertTrue(mock_execute.call_args[1]['run_as_root']) mock_get_mntp_share.reset_mock() mock_get_mntp_share.return_value = test_hashpath @@ -778,8 +777,7 @@ class GlusterFsDriverTestCase(test.TestCase): cmd = ['umount', test_hashpath] self.assertEqual(cmd[0], mock_execute.call_args[0][0]) self.assertEqual(cmd[1], mock_execute.call_args[0][1]) - self.assertEqual(True, - mock_execute.call_args[1]['run_as_root']) + self.assertTrue(mock_execute.call_args[1]['run_as_root']) def test_do_umount_with_excp1(self): test_share = '127.7.7.7:/gluster1' diff --git a/cinder/tests/test_gpfs.py b/cinder/tests/test_gpfs.py index 6780bc5b0..f2c8aebf3 100644 --- a/cinder/tests/test_gpfs.py +++ b/cinder/tests/test_gpfs.py @@ -102,8 +102,8 @@ class GPFSDriverTestCase(test.TestCase): 'nodesUp:totalNodes:remarks:cnfsState:\n' 'mmgetstate::0:1:::devstack:3:active:2:3:3:' 'quorum node:(undefined):', '') - self.assertEqual(True, self.driver._get_gpfs_state().splitlines()[1]. - startswith('mmgetstate::0:1:::devstack')) + self.assertTrue(self.driver._get_gpfs_state().splitlines()[1]. + startswith('mmgetstate::0:1:::devstack')) @mock.patch('cinder.utils.execute') def test_get_gpfs_state_fail_mmgetstate(self, mock_exec): @@ -780,8 +780,8 @@ class GPFSDriverTestCase(test.TestCase): org_value = self.driver.configuration.gpfs_sparse_volumes self.flags(volume_driver=self.driver_name, gpfs_sparse_volumes=False) self.driver.create_volume(volume) - self.assertEqual(True, self.driver._set_volume_attributes(volume, - 'test', metadata)) + self.assertTrue(self.driver._set_volume_attributes(volume, 'test', + metadata)) self.flags(volume_driver=self.driver_name, gpfs_sparse_volumes=org_value) @@ -846,8 +846,8 @@ class GPFSDriverTestCase(test.TestCase): mock_set_volume_attributes.return_value = True metadata = [{'key': 'fake_key', 'value': 'fake_value'}] - self.assertEqual(True, self.driver._set_volume_attributes(volume, - 'test', metadata)) + self.assertTrue(self.driver._set_volume_attributes(volume, 'test', + metadata)) self.assertEqual(self.driver.create_volume_from_snapshot(volume, snapshot), {'size': 5.0}) @@ -898,8 +898,8 @@ class GPFSDriverTestCase(test.TestCase): mock_set_volume_attributes.return_value = True metadata = [{'key': 'fake_key', 'value': 'fake_value'}] - self.assertEqual(True, self.driver._set_volume_attributes(volume, - 'test', metadata)) + self.assertTrue(self.driver._set_volume_attributes(volume, 'test', + metadata)) self.assertEqual(self.driver.create_cloned_volume(volume, src_volume), {'size': 5.0}) @@ -968,14 +968,14 @@ class GPFSDriverTestCase(test.TestCase): ' no 2 148488 ' '/gpfs0/test.txt', ''), ('', '')] - self.assertEqual(True, self.driver._gpfs_redirect('')) + self.assertTrue(self.driver._gpfs_redirect('')) self.flags(volume_driver=self.driver_name, gpfs_max_clone_depth=1) mock_exec.side_effect = [('Parent Depth Parent inode File name\n' '------ ----- -------------- ---------\n' ' no 1 148488 ' '/gpfs0/test.txt', ''), ('', '')] - self.assertEqual(False, self.driver._gpfs_redirect('')) + self.assertFalse(self.driver._gpfs_redirect('')) self.flags(volume_driver=self.driver_name, gpfs_max_clone_depth=org_value) @@ -988,7 +988,7 @@ class GPFSDriverTestCase(test.TestCase): ' no 2 148488 ' '/gpfs0/test.txt', ''), ('', '')] - self.assertEqual(False, self.driver._gpfs_redirect('')) + self.assertFalse(self.driver._gpfs_redirect('')) self.flags(volume_driver=self.driver_name, gpfs_max_clone_depth=org_value) @@ -1001,7 +1001,7 @@ class GPFSDriverTestCase(test.TestCase): ' 148488 ' '/gpfs0/test.txt', ''), ('', '')] - self.assertEqual(False, self.driver._gpfs_redirect('')) + self.assertFalse(self.driver._gpfs_redirect('')) self.flags(volume_driver=self.driver_name, gpfs_max_clone_depth=org_value) @@ -1038,8 +1038,8 @@ class GPFSDriverTestCase(test.TestCase): '------ ----- -------------- ---------\n' ' no 2 148488 ' '/gpfs0/test.txt', '')] - self.assertEqual(True, self.driver._is_gpfs_parent_file('')) - self.assertEqual(False, self.driver._is_gpfs_parent_file('')) + self.assertTrue(self.driver._is_gpfs_parent_file('')) + self.assertFalse(self.driver._is_gpfs_parent_file('')) @mock.patch('cinder.volume.drivers.ibm.gpfs.GPFSDriver._gpfs_redirect') @mock.patch('cinder.volume.drivers.ibm.gpfs.GPFSDriver.' diff --git a/cinder/tests/test_hplefthand.py b/cinder/tests/test_hplefthand.py index 2a7f9684e..9e3e2608c 100644 --- a/cinder/tests/test_hplefthand.py +++ b/cinder/tests/test_hplefthand.py @@ -886,7 +886,7 @@ class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase): # validate self.assertEqual('iscsi', result['driver_volume_type']) - self.assertEqual(False, result['data']['target_discovered']) + self.assertFalse(result['data']['target_discovered']) self.assertEqual(self.volume_id, result['data']['volume_id']) self.assertTrue('auth_method' not in result['data']) @@ -939,7 +939,7 @@ class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase): # validate self.assertEqual('iscsi', result['driver_volume_type']) - self.assertEqual(False, result['data']['target_discovered']) + self.assertFalse(result['data']['target_discovered']) self.assertEqual(self.volume_id, result['data']['volume_id']) self.assertTrue('auth_method' not in result['data']) @@ -986,7 +986,7 @@ class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase): # validate self.assertEqual('iscsi', result['driver_volume_type']) - self.assertEqual(False, result['data']['target_discovered']) + self.assertFalse(result['data']['target_discovered']) self.assertEqual(self.volume_id, result['data']['volume_id']) self.assertEqual('CHAP', result['data']['auth_method']) diff --git a/cinder/tests/test_ibm_flashsystem.py b/cinder/tests/test_ibm_flashsystem.py index 70791cb1a..7c3263ad4 100644 --- a/cinder/tests/test_ibm_flashsystem.py +++ b/cinder/tests/test_ibm_flashsystem.py @@ -1053,8 +1053,8 @@ class FlashSystemDriverTestCase(test.TestCase): vol1['name'], vol1['id'], vol2['name'], vol2['id']) (v1_mapped, lun) = self.driver._is_vdisk_map(vol1['name'], connector) (v2_mapped, lun) = self.driver._is_vdisk_map(vol2['name'], connector) - self.assertEqual(False, v1_mapped) - self.assertEqual(False, v2_mapped) + self.assertFalse(v1_mapped) + self.assertFalse(v2_mapped) # case 2: mapped before copy self.driver.initialize_connection(vol1, connector) @@ -1063,8 +1063,8 @@ class FlashSystemDriverTestCase(test.TestCase): vol1['name'], vol1['id'], vol2['name'], vol2['id']) (v1_mapped, lun) = self.driver._is_vdisk_map(vol1['name'], connector) (v2_mapped, lun) = self.driver._is_vdisk_map(vol2['name'], connector) - self.assertEqual(True, v1_mapped) - self.assertEqual(True, v2_mapped) + self.assertTrue(v1_mapped) + self.assertTrue(v2_mapped) self.driver.terminate_connection(vol1, connector) self.driver.terminate_connection(vol2, connector) @@ -1076,8 +1076,8 @@ class FlashSystemDriverTestCase(test.TestCase): vol1['name'], vol1['id'], vol2['name'], vol2['id']) (v1_mapped, lun) = self.driver._is_vdisk_map(vol1['name'], connector) (v2_mapped, lun) = self.driver._is_vdisk_map(vol2['name'], connector) - self.assertEqual(False, v1_mapped) - self.assertEqual(False, v2_mapped) + self.assertFalse(v1_mapped) + self.assertFalse(v2_mapped) # case 4: no mapped before copy, raise exception when copy copy_volume.side_effect = exception.VolumeBackendAPIException @@ -1087,8 +1087,8 @@ class FlashSystemDriverTestCase(test.TestCase): vol1['name'], vol1['id'], vol2['name'], vol2['id']) (v1_mapped, lun) = self.driver._is_vdisk_map(vol1['name'], connector) (v2_mapped, lun) = self.driver._is_vdisk_map(vol2['name'], connector) - self.assertEqual(False, v1_mapped) - self.assertEqual(False, v2_mapped) + self.assertFalse(v1_mapped) + self.assertFalse(v2_mapped) # clear environment self.driver.delete_volume(vol1) diff --git a/cinder/tests/test_ibmnas.py b/cinder/tests/test_ibmnas.py index 114dd857d..01e8efeb0 100644 --- a/cinder/tests/test_ibmnas.py +++ b/cinder/tests/test_ibmnas.py @@ -268,8 +268,8 @@ class IBMNASDriverTestCase(test.TestCase): drv = self._driver mock_size.return_value = True - self.assertEqual(True, drv._resize_volume_file(self.TEST_LOCAL_PATH, - self.TEST_EXTEND_SIZE_IN_GB)) + self.assertTrue(drv._resize_volume_file(self.TEST_LOCAL_PATH, + self.TEST_EXTEND_SIZE_IN_GB)) @mock.patch('cinder.image.image_utils.resize_image') def test_resize_volume_exception(self, mock_size): diff --git a/cinder/tests/test_prophetstor_dpl.py b/cinder/tests/test_prophetstor_dpl.py index 5ea48ed5f..e98336ea1 100644 --- a/cinder/tests/test_prophetstor_dpl.py +++ b/cinder/tests/test_prophetstor_dpl.py @@ -460,7 +460,7 @@ class TestProphetStorDPLDriver(test.TestCase): self.assertEqual(4, pool['total_capacity_gb']) self.assertEqual(4, pool['free_capacity_gb']) self.assertEqual(0, pool['reserved_percentage']) - self.assertEqual(False, pool['QoS_support']) + self.assertFalse(pool['QoS_support']) def test_create_volume(self): self.DPL_MOCK.create_vdev.return_value = DATA_OUTPUT @@ -576,7 +576,7 @@ class TestProphetStorDPLDriver(test.TestCase): DATA_IN_CONNECTOR) self.assertEqual('iscsi', res['driver_volume_type']) self.assertEqual('101', res['data']['target_lun']) - self.assertEqual(True, res['data']['target_discovered']) + self.assertTrue(res['data']['target_discovered']) self.assertEqual('172.31.1.210:3260', res['data']['target_portal']) self.assertEqual( 'iqn.2013-09.com.prophetstor:hypervisor.886423051816', diff --git a/cinder/tests/test_smbfs.py b/cinder/tests/test_smbfs.py index 75fb43188..aa1dd69fe 100644 --- a/cinder/tests/test_smbfs.py +++ b/cinder/tests/test_smbfs.py @@ -239,28 +239,28 @@ class SmbFsTestCase(test.TestCase): fake_volume_size = 2 ret_value = self._test_is_share_eligible(fake_capacity_info, fake_volume_size) - self.assertEqual(ret_value, False) + self.assertFalse(ret_value) def test_eligible_share(self): fake_capacity_info = (4, 4, 0) fake_volume_size = 1 ret_value = self._test_is_share_eligible(fake_capacity_info, fake_volume_size) - self.assertEqual(ret_value, True) + self.assertTrue(ret_value) def test_share_volume_above_oversub_ratio(self): fake_capacity_info = (4, 4, 7) fake_volume_size = 2 ret_value = self._test_is_share_eligible(fake_capacity_info, fake_volume_size) - self.assertEqual(ret_value, False) + self.assertFalse(ret_value) def test_share_reserved_above_oversub_ratio(self): fake_capacity_info = (4, 4, 10) fake_volume_size = 1 ret_value = self._test_is_share_eligible(fake_capacity_info, fake_volume_size) - self.assertEqual(ret_value, False) + self.assertFalse(ret_value) def test_parse_options(self): (opt_list, diff --git a/cinder/tests/test_storpool.py b/cinder/tests/test_storpool.py index 36a059823..5f6054ce2 100644 --- a/cinder/tests/test_storpool.py +++ b/cinder/tests/test_storpool.py @@ -214,7 +214,7 @@ class StorPoolTestCase(test.TestCase): 'volume_type': None}) except exception.VolumeBackendAPIException: caught = True - self.assertEqual(True, caught) + self.assertTrue(caught) self.driver.delete_volume({'id': '1'}) self.assertVolumeNames([]) diff --git a/cinder/tests/test_v6000_fcp.py b/cinder/tests/test_v6000_fcp.py index a28ac7ae0..c796446cb 100644 --- a/cinder/tests/test_v6000_fcp.py +++ b/cinder/tests/test_v6000_fcp.py @@ -224,7 +224,7 @@ class V6000FCPDriverTestCase(test.TestCase): self.driver._build_initiator_target_map.assert_called_with( CONNECTOR) self.assertEqual("fibre_channel", props['driver_volume_type']) - self.assertEqual(True, props['data']['target_discovered']) + self.assertTrue(props['data']['target_discovered']) self.assertEqual(target_wwns, props['data']['target_wwn']) self.assertEqual(lun_id, props['data']['target_lun']) self.assertEqual(init_targ_map, props['data']['initiator_target_map']) @@ -249,7 +249,7 @@ class V6000FCPDriverTestCase(test.TestCase): self.driver._build_initiator_target_map.assert_called_with( CONNECTOR) self.assertEqual("fibre_channel", props['driver_volume_type']) - self.assertEqual(True, props['data']['target_discovered']) + self.assertTrue(props['data']['target_discovered']) self.assertEqual(target_wwns, props['data']['target_wwn']) self.assertEqual(lun_id, props['data']['target_lun']) self.assertEqual(init_targ_map, props['data']['initiator_target_map']) diff --git a/cinder/tests/test_volume.py b/cinder/tests/test_volume.py index 3b9eeb245..383790018 100644 --- a/cinder/tests/test_volume.py +++ b/cinder/tests/test_volume.py @@ -721,7 +721,7 @@ class VolumeTestCase(BaseVolumeTestCase): volume_name='fake')) self.mox.ReplayAll() res = self.volume.delete_volume(self.context, volume_id) - self.assertEqual(True, res) + self.assertTrue(res) volume_ref = db.volume_get(context.get_admin_context(), volume_id) self.assertEqual(volume_id, volume_ref.id) self.assertEqual("available", volume_ref.status) @@ -4442,7 +4442,7 @@ class LVMISCSIVolumeDriverTestCase(DriverTestCase): vol = {'name': 'test', 'id': 1, 'size': 1, 'status': 'available'} moved, model_update = self.volume.driver.migrate_volume(self.context, vol, host) - self.assertEqual(moved, False) + self.assertFalse(moved) self.assertIsNone(model_update) def test_lvm_migrate_volume_bad_loc_info(self): @@ -4451,7 +4451,7 @@ class LVMISCSIVolumeDriverTestCase(DriverTestCase): vol = {'name': 'test', 'id': 1, 'size': 1, 'status': 'available'} moved, model_update = self.volume.driver.migrate_volume(self.context, vol, host) - self.assertEqual(moved, False) + self.assertFalse(moved) self.assertIsNone(model_update) def test_lvm_migrate_volume_diff_driver(self): @@ -4460,7 +4460,7 @@ class LVMISCSIVolumeDriverTestCase(DriverTestCase): vol = {'name': 'test', 'id': 1, 'size': 1, 'status': 'available'} moved, model_update = self.volume.driver.migrate_volume(self.context, vol, host) - self.assertEqual(moved, False) + self.assertFalse(moved) self.assertIsNone(model_update) def test_lvm_migrate_volume_diff_host(self): @@ -4469,7 +4469,7 @@ class LVMISCSIVolumeDriverTestCase(DriverTestCase): vol = {'name': 'test', 'id': 1, 'size': 1, 'status': 'available'} moved, model_update = self.volume.driver.migrate_volume(self.context, vol, host) - self.assertEqual(moved, False) + self.assertFalse(moved) self.assertIsNone(model_update) def test_lvm_migrate_volume_in_use(self): @@ -4479,7 +4479,7 @@ class LVMISCSIVolumeDriverTestCase(DriverTestCase): vol = {'name': 'test', 'id': 1, 'size': 1, 'status': 'in-use'} moved, model_update = self.volume.driver.migrate_volume(self.context, vol, host) - self.assertEqual(moved, False) + self.assertFalse(moved) self.assertIsNone(model_update) @mock.patch.object(volutils, 'get_all_volume_groups', @@ -4519,7 +4519,7 @@ class LVMISCSIVolumeDriverTestCase(DriverTestCase): moved, model_update = self.volume.driver.migrate_volume(self.context, vol, host) - self.assertEqual(moved, False) + self.assertFalse(moved) self.assertIsNone(model_update) def test_lvm_migrate_volume_proceed(self): @@ -4565,7 +4565,7 @@ class LVMISCSIVolumeDriverTestCase(DriverTestCase): 'default') moved, model_update = self.volume.driver.migrate_volume(self.context, vol, host) - self.assertEqual(moved, True) + self.assertTrue(moved) self.assertIsNone(model_update) @staticmethod diff --git a/cinder/tests/test_volume_types.py b/cinder/tests/test_volume_types.py index b6abc15a8..e81ab8fd1 100644 --- a/cinder/tests/test_volume_types.py +++ b/cinder/tests/test_volume_types.py @@ -293,11 +293,11 @@ class VolumeTypeTestCase(test.TestCase): # Check equality with only extra_specs diff, same = volume_types.volume_types_diff(self.ctxt, type_ref1['id'], type_ref2['id']) - self.assertEqual(same, True) + self.assertTrue(same) self.assertEqual(diff['extra_specs']['key1'], ('val1', 'val1')) diff, same = volume_types.volume_types_diff(self.ctxt, type_ref1['id'], type_ref3['id']) - self.assertEqual(same, False) + self.assertFalse(same) self.assertEqual(diff['extra_specs']['key1'], ('val1', 'val0')) # qos_ref 1 and 2 have the same specs, while 3 has different @@ -314,7 +314,7 @@ class VolumeTypeTestCase(test.TestCase): type_ref2['id']) diff, same = volume_types.volume_types_diff(self.ctxt, type_ref1['id'], type_ref2['id']) - self.assertEqual(same, True) + self.assertTrue(same) self.assertEqual(diff['extra_specs']['key1'], ('val1', 'val1')) self.assertEqual(diff['qos_specs']['k1'], ('v1', 'v1')) qos_specs.disassociate_qos_specs(self.ctxt, qos_ref2['id'], @@ -323,7 +323,7 @@ class VolumeTypeTestCase(test.TestCase): type_ref2['id']) diff, same = volume_types.volume_types_diff(self.ctxt, type_ref1['id'], type_ref2['id']) - self.assertEqual(same, False) + self.assertFalse(same) self.assertEqual(diff['extra_specs']['key1'], ('val1', 'val1')) self.assertEqual(diff['qos_specs']['k1'], ('v1', 'v0')) qos_specs.disassociate_qos_specs(self.ctxt, qos_ref3['id'], @@ -344,7 +344,7 @@ class VolumeTypeTestCase(test.TestCase): enc_keyvals2) diff, same = volume_types.volume_types_diff(self.ctxt, type_ref1['id'], type_ref2['id']) - self.assertEqual(same, False) + self.assertFalse(same) self.assertEqual(diff['extra_specs']['key1'], ('val1', 'val1')) self.assertEqual(diff['qos_specs']['k1'], ('v1', 'v1')) self.assertEqual(diff['encryption']['key_size'], (256, 128)) @@ -352,7 +352,7 @@ class VolumeTypeTestCase(test.TestCase): # Check diff equals type specs when one type is None diff, same = volume_types.volume_types_diff(self.ctxt, None, type_ref1['id']) - self.assertEqual(same, False) + self.assertFalse(same) self.assertEqual(diff['extra_specs'], {'key1': (None, 'val1'), 'key2': (None, 'val2')}) self.assertEqual(diff['qos_specs'], -- 2.45.2