Don't depend on string interning

Use '==' instead of 'is' to compare strings.

In practice, short strings that appear in the source code are interned
in CPython, but this is implementation-specific.

Change-Id: I582029629afa9f3b8f6890f6b8c668d70de9f836
This commit is contained in:
Zane Bitter 2018-05-14 16:24:29 -04:00
parent 471308d662
commit 3123e7d75b
3 changed files with 8 additions and 8 deletions

View File

@ -643,7 +643,7 @@ class CinderVolumeTest(vt_base.VolumeTestCase):
vt_base.FakeVolume('available')
]
extra_get_mocks = [fv1, fv2, fvd, vt_base.FakeVolume('available')]
if update_type is 'resize':
if update_type == 'resize':
extra_get_mocks += resize_m_get
extra_get_mocks.append(fv3_ready)
self._mock_create_volume(vt_base.FakeVolume('creating'), stack_name,
@ -653,7 +653,7 @@ class CinderVolumeTest(vt_base.VolumeTestCase):
self.fc.volumes.get_server_volume.side_effect = [
fvd, fvd, fakes_nova.fake_exception()]
if update_type is 'access_mode':
if update_type == 'access_mode':
# update access mode script
update_readonly_mock = self.patchobject(self.cinder_fc.volumes,
'update_readonly_flag',
@ -665,9 +665,9 @@ class CinderVolumeTest(vt_base.VolumeTestCase):
self.create_attachment(self.t, stack, 'attachment')
props = copy.deepcopy(rsrc.properties.data)
if update_type is 'access_mode':
if update_type == 'access_mode':
props['read_only'] = True
if update_type is 'resize':
if update_type == 'resize':
props['size'] = 2
after = rsrc_defn.ResourceDefinition(rsrc.name, rsrc.type(), props)
@ -676,10 +676,10 @@ class CinderVolumeTest(vt_base.VolumeTestCase):
self.assertEqual((rsrc.UPDATE, rsrc.COMPLETE), rsrc.state)
if update_type is 'access_mode':
if update_type == 'access_mode':
update_readonly_mock.assert_called_once_with(fvd.id, True)
if update_type is 'resize':
if update_type == 'resize':
self.cinder_fc.volumes.extend.assert_called_once_with(fvd.id, 2)
self.fc.volumes.get_server_volume.assert_called_with(
u'WikiDatabase', 'vol-123')

View File

@ -456,7 +456,7 @@ class TestMistralWorkflow(common.HeatTestCase):
self.assertEqual(expected_state, wf.state)
self.assertEqual('create_vm', wf.resource_id)
for task in wf.properties['tasks']:
if task['name'] is 'wait_instance':
if task['name'] == 'wait_instance':
self.assertEqual(5, task['retry']['delay'])
self.assertEqual(15, task['retry']['count'])
break

View File

@ -644,7 +644,7 @@ class PropertySchemaTest(common.HeatTestCase):
{'res': resource_type,
'prop': prop_key,
'nested_prop': sub_prop_key})
if sub_prop_key is '*':
if sub_prop_key == '*':
check_update_policy(resource_type, prop_key,
sub_prop, update)
else: