From 6c084991bfdafda7d75d0a49d4359b42b9c6451f Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt Date: Thu, 26 Jul 2012 19:35:12 +0000 Subject: Avoid using 'is' operator when comparing strings The 'is' operator compares identity, not value. Python doesn't guarantee that two strings that are the same will also be the same object. Change-Id: I2d7e7947b14272fa2a82d5e8eefa95dcaba375f7 --- nova/api/openstack/__init__.py | 2 +- nova/tests/test_SolidFireSanISCSIDriver.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py index a2f73e852..a5274e03b 100644 --- a/nova/api/openstack/__init__.py +++ b/nova/api/openstack/__init__.py @@ -80,7 +80,7 @@ class FaultWrapper(base_wsgi.Middleware): class APIMapper(routes.Mapper): def routematch(self, url=None, environ=None): - if url is "": + if url == "": result = self._match("", environ) return result[0], result[1] return routes.Mapper.routematch(self, url, environ) diff --git a/nova/tests/test_SolidFireSanISCSIDriver.py b/nova/tests/test_SolidFireSanISCSIDriver.py index 9e1e69019..60c1a63e0 100644 --- a/nova/tests/test_SolidFireSanISCSIDriver.py +++ b/nova/tests/test_SolidFireSanISCSIDriver.py @@ -28,7 +28,7 @@ class SolidFireVolumeTestCase(test.TestCase): super(SolidFireVolumeTestCase, self).setUp() def fake_issue_api_request(obj, method, params): - if method is 'GetClusterInfo': + if method == 'GetClusterInfo': LOG.info('Called Fake GetClusterInfo...') results = {'result': {'clusterInfo': {'name': 'fake-cluster', @@ -39,11 +39,11 @@ class SolidFireVolumeTestCase(test.TestCase): 'attributes': {}}}} return results - elif method is 'AddAccount': + elif method == 'AddAccount': LOG.info('Called Fake AddAccount...') return {'result': {'accountID': 25}, 'id': 1} - elif method is 'GetAccountByName': + elif method == 'GetAccountByName': LOG.info('Called Fake GetAccountByName...') results = {'result': {'account': { 'accountID': 25, @@ -56,15 +56,15 @@ class SolidFireVolumeTestCase(test.TestCase): "id": 1} return results - elif method is 'CreateVolume': + elif method == 'CreateVolume': LOG.info('Called Fake CreateVolume...') return {'result': {'volumeID': 5}, 'id': 1} - elif method is 'DeleteVolume': + elif method == 'DeleteVolume': LOG.info('Called Fake DeleteVolume...') return {'result': {}, 'id': 1} - elif method is 'ListVolumesForAccount': + elif method == 'ListVolumesForAccount': LOG.info('Called Fake ListVolumesForAccount...') result = {'result': {'volumes': [{ 'volumeID': '5', -- cgit