From 03665ece43c357a212ace93067c55d84e1964fae Mon Sep 17 00:00:00 2001 From: melissaml Date: Wed, 8 Jul 2020 10:26:23 +0800 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: I1017da7f2819b3d6d83f648187ab28216f7a5efc --- .../model/repositories/test_repositories_quotas.py | 14 +++++++------- barbican/tests/objects/test_ovo_project_quotas.py | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/barbican/tests/model/repositories/test_repositories_quotas.py b/barbican/tests/model/repositories/test_repositories_quotas.py index a4ccd3ce2..d5355b575 100644 --- a/barbican/tests/model/repositories/test_repositories_quotas.py +++ b/barbican/tests/model/repositories/test_repositories_quotas.py @@ -100,21 +100,21 @@ class WhenTestingProjectQuotasRepo(database_utils.RepositoryTestCase): self.assertEqual(0, offset) self.assertEqual(10, limit) self.assertEqual(2, total) - self.assertItemsEqual([self.project_1.id, self.project_2.id], + self.assertCountEqual([self.project_1.id, self.project_2.id], [s.project_id for s in retrieved_project_quotas]) - self.assertItemsEqual([self.project_1.external_id, + self.assertCountEqual([self.project_1.external_id, self.project_2.external_id], [s.project.external_id for s in retrieved_project_quotas]) - self.assertItemsEqual([101, 201], + self.assertCountEqual([101, 201], [s.secrets for s in retrieved_project_quotas]) - self.assertItemsEqual([102, 202], + self.assertCountEqual([102, 202], [s.orders for s in retrieved_project_quotas]) - self.assertItemsEqual([103, 203], + self.assertCountEqual([103, 203], [s.containers for s in retrieved_project_quotas]) - self.assertItemsEqual([105, 205], + self.assertCountEqual([105, 205], [s.consumers for s in retrieved_project_quotas]) - self.assertItemsEqual([106, 206], + self.assertCountEqual([106, 206], [s.cas for s in retrieved_project_quotas]) def test_should_raise_get_list_of_zero_project_quotas(self): diff --git a/barbican/tests/objects/test_ovo_project_quotas.py b/barbican/tests/objects/test_ovo_project_quotas.py index 7fe7c507e..fb1cb1612 100644 --- a/barbican/tests/objects/test_ovo_project_quotas.py +++ b/barbican/tests/objects/test_ovo_project_quotas.py @@ -97,21 +97,21 @@ class TestProjectQuotas(test_ovo_base.OVOTestCase): self.assertEqual(0, offset) self.assertEqual(10, limit) self.assertEqual(2, total) - self.assertItemsEqual([self.project_id1, self.project_id2], + self.assertCountEqual([self.project_id1, self.project_id2], [s.project_id for s in retrieved_project_quotas]) - self.assertItemsEqual([self.external_id1, + self.assertCountEqual([self.external_id1, self.external_id2], [s.project.external_id for s in retrieved_project_quotas]) - self.assertItemsEqual([101, 201], + self.assertCountEqual([101, 201], [s.secrets for s in retrieved_project_quotas]) - self.assertItemsEqual([102, 202], + self.assertCountEqual([102, 202], [s.orders for s in retrieved_project_quotas]) - self.assertItemsEqual([103, 203], + self.assertCountEqual([103, 203], [s.containers for s in retrieved_project_quotas]) - self.assertItemsEqual([105, 205], + self.assertCountEqual([105, 205], [s.consumers for s in retrieved_project_quotas]) - self.assertItemsEqual([106, 206], + self.assertCountEqual([106, 206], [s.cas for s in retrieved_project_quotas]) def test_ovo_should_raise_get_list_of_zero_project_quotas(self):