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
This commit is contained in:
melissaml 2020-07-08 10:26:23 +08:00
parent 71bad5df06
commit 03665ece43
2 changed files with 14 additions and 14 deletions

View File

@ -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):

View File

@ -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):