From a95aef8dc82f401a255f54bdaf89b605a0010bc8 Mon Sep 17 00:00:00 2001 From: Ludovic Beliveau Date: Fri, 6 May 2016 19:21:56 -0400 Subject: [PATCH] Fixes py3 unit tests for nova.tests.unit.test_block_device.* - test_mappings_prepend_dev: Unorderable types: python3 ignores cmp on dict. Use sorted instead. - test_from_legacy_mapping: There is a fake bdms with a 'boot_index' of None. This caused issue when trying to compare it with an integer. Change-Id: I9d77181b136a5ea611afaf42153bd99a77b4d570 Partially-Implements: blueprint nova-python3-newton --- nova/tests/unit/test_block_device.py | 7 +++++-- tests-py3.txt | 2 -- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/nova/tests/unit/test_block_device.py b/nova/tests/unit/test_block_device.py index 2777cbc67013..884dd878da1d 100644 --- a/nova/tests/unit/test_block_device.py +++ b/nova/tests/unit/test_block_device.py @@ -120,7 +120,8 @@ class BlockDeviceTestCase(test.NoDBTestCase): {'virtual': 'ephemeral2', 'device': '/dev/sde'}] prepended = block_device.mappings_prepend_dev(mapping) - self.assertEqual(expected.sort(), prepended.sort()) + self.assertEqual(sorted(expected, key=lambda v: v['virtual']), + sorted(prepended, key=lambda v: v['virtual'])) def test_strip_dev(self): self.assertEqual('sda', block_device.strip_dev('/dev/sda')) @@ -499,7 +500,9 @@ class TestBlockDeviceDict(test.NoDBTestCase): return [bdm for bdm in bdms if bdm['source_type'] == 'image'] def _get_bootable_bdms(bdms): - return [bdm for bdm in bdms if bdm['boot_index'] >= 0] + return [bdm for bdm in bdms + if (bdm['boot_index'] is not None and + bdm['boot_index'] >= 0)] new_no_img = block_device.from_legacy_mapping(self.legacy_mapping) self.assertEqual(0, len(_get_image_bdms(new_no_img))) diff --git a/tests-py3.txt b/tests-py3.txt index 94fc07291be9..1345faca83c2 100644 --- a/tests-py3.txt +++ b/tests-py3.txt @@ -89,8 +89,6 @@ nova.tests.unit.pci.test_stats.PciDeviceStatsTestCase nova.tests.unit.pci.test_stats.PciDeviceStatsWithTagsTestCase nova.tests.unit.test_api_validation.Base64TestCase nova.tests.unit.test_bdm.BlockDeviceMappingEc2CloudTestCase -nova.tests.unit.test_block_device.BlockDeviceTestCase -nova.tests.unit.test_block_device.TestBlockDeviceDict nova.tests.unit.test_cinder.CinderTestCase nova.tests.unit.test_cinder.CinderV2TestCase nova.tests.unit.test_configdrive2.ConfigDriveTestCase