Fix "is"/"is not" with a literal usage

Python 3.8 throws a SyntaxWarning for these,
should use "==" or "!=" instead of "is" or "is not".

Change-Id: Id7131a34f5c4c44b15bed5ac1bc9f10d0d72d7ca
This commit is contained in:
Eric Harney 2019-11-08 09:33:38 -05:00
parent 821cc703c0
commit 3182a9c92a
8 changed files with 26 additions and 26 deletions

View File

@ -997,7 +997,7 @@ class AS13000DriverTestCase(test.TestCase):
host_exist, target_name, node = (
self.as13000_san._get_target_from_conn(host_ip))
if host_ip is 'fake_ip3':
if host_ip == 'fake_ip3':
self.assertEqual((True, 'fake_target_2',
['fake_node4', 'fake_node3']),
(host_exist, target_name, node))

View File

@ -535,7 +535,7 @@ class NominatePoolLDTest(volume_helper.MStorageDSVDriver, test.TestCase):
# config:pool_backup_pools=[2]
self.pools[1]['free'] = savePool1
if len(self.pools[0]['ld_list']) is 1024:
if len(self.pools[0]['ld_list']) == 1024:
savePool2 = self.pools[2]['free']
savePool3 = self.pools[3]['free']
self.pools[2]['free'] = 0

View File

@ -183,7 +183,7 @@ class SolidFireVolumeTestCase(test.TestCase):
def fake_issue_api_request(obj, method, params, version='1.0',
endpoint=None):
if method is 'GetClusterCapacity':
if method == 'GetClusterCapacity':
data = {}
if version == '1.0':
data = {'result': {'clusterCapacity': {
@ -220,7 +220,7 @@ class SolidFireVolumeTestCase(test.TestCase):
'clusterRecentIOSize': 0}}}
return data
elif method is 'GetClusterInfo':
elif method == 'GetClusterInfo':
results = {
'result':
{'clusterInfo':
@ -233,7 +233,7 @@ class SolidFireVolumeTestCase(test.TestCase):
'attributes': {}}}}
return results
elif method is 'GetClusterVersionInfo':
elif method == 'GetClusterVersionInfo':
return {'id': None, 'result': {'softwareVersionInfo':
{'pendingVersion': '8.2.1.4',
'packageName': '',
@ -242,10 +242,10 @@ class SolidFireVolumeTestCase(test.TestCase):
'clusterVersion': '8.2.1.4',
'clusterAPIVersion': '8.2'}}
elif method is 'AddAccount' and version == '1.0':
elif method == 'AddAccount' and version == '1.0':
return {'result': {'accountID': 25}, 'id': 1}
elif method is 'GetAccountByName' and version == '1.0':
elif method == 'GetAccountByName' and version == '1.0':
results = {'result': {'account':
{'accountID': 25,
'username': params['username'],
@ -257,25 +257,25 @@ class SolidFireVolumeTestCase(test.TestCase):
"id": 1}
return results
elif method is 'CreateVolume' and version == '1.0':
elif method == 'CreateVolume' and version == '1.0':
return {'result': {'volumeID': 5}, 'id': 1}
elif method is 'CreateSnapshot' and version == '6.0':
elif method == 'CreateSnapshot' and version == '6.0':
return {'result': {'snapshotID': 5}, 'id': 1}
elif method is 'DeleteVolume' and version == '1.0':
elif method == 'DeleteVolume' and version == '1.0':
return {'result': {}, 'id': 1}
elif method is 'ModifyVolume' and version == '5.0':
elif method == 'ModifyVolume' and version == '5.0':
return {'result': {}, 'id': 1}
elif method is 'CloneVolume':
elif method == 'CloneVolume':
return {'result': {'volumeID': 6}, 'id': 2}
elif method is 'ModifyVolume':
elif method == 'ModifyVolume':
return {'result': {}, 'id': 1}
elif method is 'ListVolumesForAccount' and version == '1.0':
elif method == 'ListVolumesForAccount' and version == '1.0':
test_name = 'OS-VOLID-a720b3c0-d1f0-11e1-9b23-0800200c9a66'
result = {'result': {
'volumes': [{'volumeID': 5,
@ -291,7 +291,7 @@ class SolidFireVolumeTestCase(test.TestCase):
'iqn': test_name}]}}
return result
elif method is 'ListActiveVolumes':
elif method == 'ListActiveVolumes':
test_name = "existing_volume"
result = {'result': {
'volumes': [{'volumeID': 5,
@ -306,7 +306,7 @@ class SolidFireVolumeTestCase(test.TestCase):
'qos': None,
'iqn': test_name}]}}
return result
elif method is 'ListVolumes':
elif method == 'ListVolumes':
test_name = "get_sfvol_by_cinder"
result = {'result': {
'volumes': [{'volumeID': 5,
@ -337,13 +337,13 @@ class SolidFireVolumeTestCase(test.TestCase):
!= params['startVolumeID']]
result['result']['volumes'] = selected_volumes
return result
elif method is 'DeleteSnapshot':
elif method == 'DeleteSnapshot':
return {'result': {}}
elif method is 'GetClusterVersionInfo':
elif method == 'GetClusterVersionInfo':
return {'result': {'clusterAPIVersion': '8.0'}}
elif method is 'StartVolumePairing':
elif method == 'StartVolumePairing':
return {'result': {'volumePairingKey': 'fake-pairing-key'}}
elif method is 'RollbackToSnapshot':
elif method == 'RollbackToSnapshot':
return {
"id": 1,
"result": {
@ -368,7 +368,7 @@ class SolidFireVolumeTestCase(test.TestCase):
"snapshotID": 1
}
}
elif method is 'ListAccounts':
elif method == 'ListAccounts':
return {
'result': {
'accounts': [{

View File

@ -506,7 +506,7 @@ class PureDriverTestCase(test.TestCase):
self.purestorage_module.PureHTTPError = FakePureStorageHTTPError
def fake_get_array(*args, **kwargs):
if 'action' in kwargs and kwargs['action'] is 'monitor':
if 'action' in kwargs and kwargs['action'] == 'monitor':
return PERF_INFO_RAW
if 'space' in kwargs and kwargs['space'] is True:

View File

@ -587,7 +587,7 @@ def get_blkdev_major_minor(path, lookup_for_file=True):
# lookup the mounted disk which the file lies on
out, _err = execute('df', path)
devpath = out.split("\n")[1].split()[0]
if devpath[0] is not '/':
if devpath[0] != '/':
# the file is on a network file system
return None
return get_blkdev_major_minor(devpath, False)

View File

@ -49,7 +49,7 @@ class RestClient(object):
def connect(self):
self.store_node_map(self.nodes)
if len(self.nodeMap) is 0:
if len(self.nodeMap) == 0:
msg = _('Unable to connect to the nodes')
raise exception.VolumeDriverException(msg)

View File

@ -175,7 +175,7 @@ class DS8KCommonHelper(object):
'the end.'))
lss_range = lss_range.replace('-', ' - ').split()
for index, lss in enumerate(lss_range):
if lss is '-':
if lss == '-':
try:
begin = int(lss_range[index - 1], 16)
end = int(lss_range[index + 1], 16)

View File

@ -890,7 +890,7 @@ class SynoCommon(object):
if os_name == 'DSM UC':
return
elif (os_name == 'DSM' and
((6 > major) or (major is 6 and minor is 0 and hotfix < 2))):
((6 > major) or (major == 6 and minor == 0 and hotfix < 2))):
m = (_('DS version %s is not supported') %
firmware_version)
raise exception.VolumeDriverException(message=m)