compute: fixes python 3 related unit tests
Fixes volume related unit tests. Fixes non-sortable None items. Fixes __getattr__ infinite recursion. Fixes is_dict_like method. Dicts in python 3.4 do not have the 'has_key' method. Partially Implements: blueprint goal-python35 Change-Id: I97efc09f7657436f706b08e0b2795f0e59ac1dcd
This commit is contained in:
parent
6b2eb7895c
commit
e6593d3a4b
@ -541,7 +541,9 @@ def instance_block_mapping(instance, bdms):
|
||||
# Right now sort by device name for deterministic
|
||||
# result.
|
||||
if ebs_devices:
|
||||
ebs_devices.sort()
|
||||
# NOTE(claudiub): python2.7 sort places None values first.
|
||||
# this sort will maintain the same behaviour for both py27 and py34.
|
||||
ebs_devices = sorted(ebs_devices, key=lambda x: (x is not None, x))
|
||||
for nebs, ebs in enumerate(ebs_devices):
|
||||
mappings['ebs%d' % nebs] = ebs
|
||||
|
||||
|
@ -123,7 +123,9 @@ class ServiceProxy(_CellProxy):
|
||||
# ComputeNode object that consumers of this Proxy don't use, we can
|
||||
# safely remove it from what's returned
|
||||
raise AttributeError
|
||||
return getattr(self._obj, key)
|
||||
# NOTE(claudiub): needed for py34 compatiblity.
|
||||
# get self._obj first, without ending into an infinite recursion.
|
||||
return getattr(self.__getattribute__("_obj"), key)
|
||||
|
||||
|
||||
def get_instances_to_sync(context, updated_since=None, project_id=None,
|
||||
|
@ -732,7 +732,7 @@ def temporary_mutation(obj, **kwargs):
|
||||
do_something_that_needed_deleted_objects()
|
||||
"""
|
||||
def is_dict_like(thing):
|
||||
return hasattr(thing, 'has_key')
|
||||
return hasattr(thing, 'has_key') or isinstance(thing, dict)
|
||||
|
||||
def get(thing, attr, default):
|
||||
if is_dict_like(thing):
|
||||
|
@ -508,7 +508,8 @@ def attach_block_devices(block_device_mapping, *attach_args, **attach_kwargs):
|
||||
|
||||
bdm.attach(*attach_args, **attach_kwargs)
|
||||
|
||||
map(_log_and_attach, block_device_mapping)
|
||||
for device in block_device_mapping:
|
||||
_log_and_attach(device)
|
||||
return block_device_mapping
|
||||
|
||||
|
||||
|
@ -32,11 +32,6 @@ nova.tests.unit.api.openstack.compute.test_volumes.BootFromVolumeTest
|
||||
nova.tests.unit.api.openstack.compute.test_volumes.VolumeApiTestV21
|
||||
nova.tests.unit.api.test_compute_req_id.RequestIdTest
|
||||
nova.tests.unit.compute.test_compute.ComputeAPITestCase.test_create_with_base64_user_data
|
||||
nova.tests.unit.compute.test_compute.ComputeTestCase.test_finish_resize_with_volumes
|
||||
nova.tests.unit.compute.test_compute.ComputeVolumeTestCase.test_boot_volume_serial
|
||||
nova.tests.unit.compute.test_compute.ComputeVolumeTestCase.test_poll_bandwidth_usage_not_implemented
|
||||
nova.tests.unit.compute.test_compute.ComputeVolumeTestCase.test_prep_block_device_over_quota_failure
|
||||
nova.tests.unit.compute.test_compute.ComputeVolumeTestCase.test_prep_block_device_with_blanks
|
||||
nova.tests.unit.compute.test_compute_cells.CellsComputeAPITestCase.test_create_with_base64_user_data
|
||||
nova.tests.unit.compute.test_compute_mgr.ComputeManagerUnitTestCase.test_run_pending_deletes
|
||||
nova.tests.unit.compute.test_host_api.ComputeHostAPICellsTestCase
|
||||
|
Loading…
Reference in New Issue
Block a user