From 441ac7c0bf74fef94678e91ae577894ca66693c8 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Thu, 11 Jun 2020 11:40:40 +0200 Subject: 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: I5e02a7ed7803e21ad2baa93fccd00a23cda3da79 --- barbicanclient/tests/v1/test_containers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/barbicanclient/tests/v1/test_containers.py b/barbicanclient/tests/v1/test_containers.py index 67eaa26..3cbdd92 100644 --- a/barbicanclient/tests/v1/test_containers.py +++ b/barbicanclient/tests/v1/test_containers.py @@ -200,7 +200,7 @@ class WhenTestingContainers(test_client.BaseEntityResource): container_req = jsonutils.loads(self.responses.last_request.text) self.assertEqual(self.container.name, container_req['name']) self.assertEqual('certificate', container_req['type']) - self.assertItemsEqual(self.container.certificate_secret_refs_json, + self.assertCountEqual(self.container.certificate_secret_refs_json, container_req['secret_refs']) def test_should_store_certificate_via_constructor(self): @@ -225,7 +225,7 @@ class WhenTestingContainers(test_client.BaseEntityResource): container_req = jsonutils.loads(self.responses.last_request.text) self.assertEqual(self.container.name, container_req['name']) self.assertEqual('certificate', container_req['type']) - self.assertItemsEqual(self.container.certificate_secret_refs_json, + self.assertCountEqual(self.container.certificate_secret_refs_json, container_req['secret_refs']) def test_should_store_rsa_via_attributes(self): @@ -249,7 +249,7 @@ class WhenTestingContainers(test_client.BaseEntityResource): container_req = jsonutils.loads(self.responses.last_request.text) self.assertEqual(self.container.name, container_req['name']) self.assertEqual('rsa', container_req['type']) - self.assertItemsEqual(self.container.rsa_secret_refs_json, + self.assertCountEqual(self.container.rsa_secret_refs_json, container_req['secret_refs']) def test_should_store_rsa_via_constructor(self): @@ -274,7 +274,7 @@ class WhenTestingContainers(test_client.BaseEntityResource): container_req = jsonutils.loads(self.responses.last_request.text) self.assertEqual(self.container.name, container_req['name']) self.assertEqual('rsa', container_req['type']) - self.assertItemsEqual(self.container.rsa_secret_refs_json, + self.assertCountEqual(self.container.rsa_secret_refs_json, container_req['secret_refs']) def test_should_get_secret_refs_when_created_using_secret_objects(self): -- cgit v1.2.1