Switch from unittest2 compat methods to Python 3.x methods
With the removal of Python 2.x we can remove the unittest2 compat wrappers and switch to assertCountEqual instead of assertItemsEqual We have been able to use them since then, because testtools required unittest2, which still included it. With testtools removing Python 2.7 support [3][4], we will lose support for assertItemsEqual, so we should switch to use assertCountEqual. [1] - https://bugs.python.org/issue17866 [2] - https://hg.python.org/cpython/rev/d9921cb6e3cd [3] - testing-cabal/testtools#286 [4] - testing-cabal/testtools#277 Change-Id: I3422e96a66b9f4fd41590ca0081bc9afff5cd666
This commit is contained in:
parent
9f931119ba
commit
f0c7508aba
@ -392,7 +392,7 @@ class CheckWorkflowUpdateTest(common.HeatTestCase):
|
||||
True, None)
|
||||
call_args, call_kwargs = mock_pcr.call_args
|
||||
actual_predecessors = call_args[4]
|
||||
self.assertItemsEqual(expected_predecessors, actual_predecessors)
|
||||
self.assertCountEqual(expected_predecessors, actual_predecessors)
|
||||
|
||||
def test_update_retrigger_check_resource_new_traversal_deletes_rsrc(
|
||||
self, mock_cru, mock_crc, mock_pcr, mock_csc):
|
||||
|
@ -348,7 +348,7 @@ class KeystoneRoleAssignmentMixinTest(common.HeatTestCase):
|
||||
({'role': 'role_1', 'user': 'user_1', 'domain': 'domain_1'},)
|
||||
]
|
||||
|
||||
self.assertItemsEqual(expected, self.roles.revoke.call_args_list)
|
||||
self.assertCountEqual(expected, self.roles.revoke.call_args_list)
|
||||
|
||||
def test_validate_1(self):
|
||||
self.test_role_assignment.properties = mock.MagicMock()
|
||||
|
@ -151,7 +151,7 @@ class NovaFlavorTest(common.HeatTestCase):
|
||||
test_tenants_add = [mock.call(value, 'new_foo'),
|
||||
mock.call(value, 'new_bar')]
|
||||
test_add = self.my_flavor.client().flavor_access.add_tenant_access
|
||||
self.assertItemsEqual(test_tenants_add,
|
||||
self.assertCountEqual(test_tenants_add,
|
||||
test_add.call_args_list)
|
||||
|
||||
def test_flavor_handle_update_remove_tenants(self):
|
||||
@ -174,7 +174,7 @@ class NovaFlavorTest(common.HeatTestCase):
|
||||
test_tenants_remove = [mock.call(value, 'foo'),
|
||||
mock.call(value, 'bar')]
|
||||
test_rem = self.my_flavor.client().flavor_access.remove_tenant_access
|
||||
self.assertItemsEqual(test_tenants_remove,
|
||||
self.assertCountEqual(test_tenants_remove,
|
||||
test_rem.call_args_list)
|
||||
|
||||
def test_flavor_show_resource(self):
|
||||
|
@ -2064,7 +2064,7 @@ class ResourceTest(common.HeatTestCase):
|
||||
-1, pcb)
|
||||
self.assertTrue(mock_create.called)
|
||||
|
||||
self.assertItemsEqual([1, 3], res.requires)
|
||||
self.assertCountEqual([1, 3], res.requires)
|
||||
self._assert_resource_lock(res.id, None, None)
|
||||
|
||||
def test_create_convergence_throws_timeout(self):
|
||||
@ -2094,7 +2094,7 @@ class ResourceTest(common.HeatTestCase):
|
||||
self.assertRaises(exception.ResourceNotAvailable,
|
||||
res.create_convergence, self.stack.t.id, {5, 3},
|
||||
'engine-007', self.dummy_timeout, self.dummy_event)
|
||||
self.assertItemsEqual([5, 3], res.requires)
|
||||
self.assertCountEqual([5, 3], res.requires)
|
||||
# The locking happens in create which we mocked out
|
||||
self._assert_resource_lock(res.id, None, None)
|
||||
|
||||
@ -2114,7 +2114,7 @@ class ResourceTest(common.HeatTestCase):
|
||||
tr()
|
||||
mock_adopt.assert_called_once_with(
|
||||
resource_data={'resource_id': 'fluffy'})
|
||||
self.assertItemsEqual([5, 3], res.requires)
|
||||
self.assertCountEqual([5, 3], res.requires)
|
||||
self._assert_resource_lock(res.id, None, None)
|
||||
|
||||
def test_adopt_convergence_bad_data(self):
|
||||
@ -2164,7 +2164,7 @@ class ResourceTest(common.HeatTestCase):
|
||||
{4, 3}, 'engine-007', 120, new_stack)
|
||||
tr()
|
||||
|
||||
self.assertItemsEqual([3, 4], res.requires)
|
||||
self.assertCountEqual([3, 4], res.requires)
|
||||
self.assertEqual(res.action, resource.Resource.UPDATE)
|
||||
self.assertEqual(res.status, resource.Resource.COMPLETE)
|
||||
self._assert_resource_lock(res.id, None, 2)
|
||||
@ -2317,7 +2317,7 @@ class ResourceTest(common.HeatTestCase):
|
||||
|
||||
self.assertEqual(new_temp.id, res.current_template_id)
|
||||
# check if requires was updated
|
||||
self.assertItemsEqual([2, 3, 4], res.requires)
|
||||
self.assertCountEqual([2, 3, 4], res.requires)
|
||||
self.assertEqual(res.action, resource.Resource.UPDATE)
|
||||
self.assertEqual(res.status, resource.Resource.FAILED)
|
||||
self._assert_resource_lock(res.id, None, 2)
|
||||
@ -2357,7 +2357,7 @@ class ResourceTest(common.HeatTestCase):
|
||||
# ensure that current_template_id was not updated
|
||||
self.assertEqual(stack.t.id, res.current_template_id)
|
||||
# ensure that requires was not updated
|
||||
self.assertItemsEqual([2], res.requires)
|
||||
self.assertCountEqual([2], res.requires)
|
||||
self._assert_resource_lock(res.id, None, 2)
|
||||
|
||||
def test_convergence_update_replace_rollback(self):
|
||||
|
Loading…
Reference in New Issue
Block a user