From 066c1c49b52de17217edfdbefe9c96e457ad23d2 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Tue, 23 Jun 2020 14:20:59 +0200 Subject: [PATCH] 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: I4fd20ef857846117b50e8d17fdf98fa4aa117262 --- os_win/tests/unit/utils/compute/test_clusterutils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/os_win/tests/unit/utils/compute/test_clusterutils.py b/os_win/tests/unit/utils/compute/test_clusterutils.py index ed07c449..beb5961d 100644 --- a/os_win/tests/unit/utils/compute/test_clusterutils.py +++ b/os_win/tests/unit/utils/compute/test_clusterutils.py @@ -186,7 +186,7 @@ class ClusterUtilsTestCase(test_base.OsWinBaseTestCase): ret = self._clusterutils.get_cluster_node_names() - self.assertItemsEqual(['node1', 'node2'], ret) + self.assertCountEqual(['node1', 'node2'], ret) @mock.patch.object(clusterutils.ClusterUtils, '_get_cluster_group_state') def test_get_vm_host(self, mock_get_state): @@ -208,14 +208,14 @@ class ClusterUtilsTestCase(test_base.OsWinBaseTestCase): mock_get_vm_groups.return_value = [dict(name='vm1'), dict(name='vm2')] ret = self._clusterutils.list_instances() - self.assertItemsEqual(['vm1', 'vm2'], ret) + self.assertCountEqual(['vm1', 'vm2'], ret) @mock.patch.object(clusterutils.ClusterUtils, '_get_vm_groups') def test_list_instance_uuids(self, mock_get_vm_groups): mock_get_vm_groups.return_value = [dict(id='uuid1'), dict(id='uuid2')] ret = self._clusterutils.list_instance_uuids() - self.assertItemsEqual(['uuid1', 'uuid2'], ret) + self.assertCountEqual(['uuid1', 'uuid2'], ret) @ddt.data(True, False) @mock.patch.object(clusterutils.ClusterUtils,