Use assertEqual instead of assertItemsEqual

The assertItemsEqual method has been removed in Python 3.3 [1] but
it was kept alive by unittest2, imported by testtools.

[1] https://bugs.python.org/issue17866

Change-Id: I410a10d4b57f6d84e2cda623f3969cc14ca0d50e
This commit is contained in:
shenxindi 2020-07-17 10:49:18 +08:00
parent ca53bfa530
commit ccc4db699a
4 changed files with 12 additions and 10 deletions

View File

@ -5324,7 +5324,7 @@ class NetAppClientCmodeTestCase(test.TestCase):
result = self.client.get_aggregate_disk_types(
fake.SHARE_AGGREGATE_NAME)
self.assertItemsEqual(expected, result)
self.assertEqual(sorted(expected), sorted(result))
mock_get_aggregate_disk_types.assert_called_once_with(
fake.SHARE_AGGREGATE_NAME)
@ -5352,7 +5352,7 @@ class NetAppClientCmodeTestCase(test.TestCase):
fake.SHARE_AGGREGATE_NAME)
self.assertIsInstance(result, list)
self.assertItemsEqual(['SATA', 'SSD'], result)
self.assertEqual(sorted(['SATA', 'SSD']), sorted(result))
mock_get_aggregate_disk_types.assert_has_calls([
mock.call(fake.SHARE_AGGREGATE_NAME),
mock.call(fake.SHARE_AGGREGATE_NAME, shared=True),

View File

@ -372,7 +372,7 @@ class PerformanceLibraryTestCase(test.TestCase):
self.fake_volumes, self.fake_aggregates)
expected_aggregate_names = ['aggr1', 'aggr2', 'aggr3']
self.assertItemsEqual(expected_aggregate_names, result)
self.assertEqual(sorted(expected_aggregate_names), sorted(result))
def test_get_nodes_for_aggregates(self):
@ -390,7 +390,8 @@ class PerformanceLibraryTestCase(test.TestCase):
expected_node_names = ['node1', 'node2']
expected_aggr_node_map = dict(zip(aggregate_names, aggregate_nodes))
self.assertItemsEqual(expected_node_names, result_node_names)
self.assertEqual(sorted(expected_node_names),
sorted(result_node_names))
self.assertEqual(expected_aggr_node_map, result_aggr_node_map)
mock_get_node_for_aggregate.assert_has_calls([
mock.call('aggr1'), mock.call('aggr2'), mock.call('aggr3')])

View File

@ -170,7 +170,7 @@ class ShareTypesTestCase(test.TestCase):
'share_type_get_all',
mock.Mock(return_value=copy.deepcopy(share_type)))
returned_type = share_types.get_all_types(self.context)
self.assertItemsEqual(share_type, returned_type)
self.assertEqual(sorted(share_type), sorted(returned_type))
def test_get_all_types_search(self):
share_type = self.fake_type_w_extra
@ -183,7 +183,7 @@ class ShareTypesTestCase(test.TestCase):
db.share_type_get_all.assert_called_once_with(
mock.ANY, 0, filters={'is_public': True})
self.assertItemsEqual(share_type, returned_type)
self.assertEqual(sorted(share_type), sorted(returned_type))
search_filter = {'extra_specs': {'gold': 'False'}}
expected_types = {}
returned_types = share_types.get_all_types(self.context,
@ -194,7 +194,7 @@ class ShareTypesTestCase(test.TestCase):
search_filter = {'extra_specs': {'gold': 'True'}}
returned_type = share_types.get_all_types(self.context,
search_opts=search_filter)
self.assertItemsEqual(share_type, returned_type)
self.assertEqual(sorted(share_type), sorted(returned_type))
@ddt.data("nova", "supernova,nova", "supernova",
"nova,hypernova,supernova")
@ -268,7 +268,8 @@ class ShareTypesTestCase(test.TestCase):
expected_return_types = (['gold', 'silver', 'default']
if len(search_azs.split(',')) < 3
else ['gold', 'default'])
self.assertItemsEqual(expected_return_types, returned_types)
self.assertEqual(sorted(expected_return_types),
sorted(returned_types))
def test_get_share_type_extra_specs(self):
share_type = self.fake_type_w_extra['test_with_extra']

View File

@ -98,7 +98,7 @@ class ShareGroupTypesTestCase(test.TestCase):
returned_type = share_group_types.get_all(self.context)
self.assertItemsEqual(share_group_type, returned_type)
self.assertEqual(sorted(share_group_type), sorted(returned_type))
def test_get_all_types_search(self):
share_group_type = self.fake_type_w_extra
@ -112,7 +112,7 @@ class ShareGroupTypesTestCase(test.TestCase):
db.share_group_type_get_all.assert_called_once_with(
mock.ANY, 0, filters={'is_public': True})
self.assertItemsEqual(share_group_type, returned_type)
self.assertEqual(sorted(share_group_type), sorted(returned_type))
search_filter = {"group_specs": {"gold": "False"}}
returned_type = share_group_types.get_all(
self.context, search_opts=search_filter)