From a602d03e2731fa37696a7c15406c74a6186e44df Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Thu, 11 Jun 2020 11:51:40 +0200 Subject: [PATCH] Replace assertItemsEqual with assertCountEqual assertItemsEqual was removed from Python's unittest.TestCase in Python 3.3 [1][2]. 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: Ib8a08f1b44712bf2fbcadecdcecd0ee3dd8ab361 --- oslo_privsep/tests/test_capabilities.py | 4 ++-- oslo_privsep/tests/test_daemon.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/oslo_privsep/tests/test_capabilities.py b/oslo_privsep/tests/test_capabilities.py index 725ea24..67d2bfc 100644 --- a/oslo_privsep/tests/test_capabilities.py +++ b/oslo_privsep/tests/test_capabilities.py @@ -34,7 +34,7 @@ class TestCapabilities(base.BaseTestCase): # Disappointingly, ffi.cast(type, 1) != ffi.cast(type, 1) # so can't just use assert_called_once_with :-( self.assertEqual(1, mock_prctl.call_count) - self.assertItemsEqual( + self.assertCountEqual( [8, 1], # [PR_SET_KEEPCAPS, true] [int(x) for x in mock_prctl.call_args[0]]) @@ -81,7 +81,7 @@ class TestCapabilities(base.BaseTestCase): return 0 mock_capget.side_effect = impl - self.assertItemsEqual( + self.assertCountEqual( ([17, 24, 49], [8, 10, 35, 56], [24, 31, 40]), diff --git a/oslo_privsep/tests/test_daemon.py b/oslo_privsep/tests/test_daemon.py index f3f3ffe..b39ce61 100644 --- a/oslo_privsep/tests/test_daemon.py +++ b/oslo_privsep/tests/test_daemon.py @@ -165,7 +165,7 @@ class DaemonTest(base.BaseTestCase): mock_setgid.assert_called_once_with(84) mock_setgroups.assert_called_once_with([]) - self.assertItemsEqual( + self.assertCountEqual( [mock.call(True), mock.call(False)], mock_keepcaps.mock_calls)