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
This commit is contained in:
Dirk Mueller 2020-06-11 11:51:40 +02:00
parent 485f396424
commit a602d03e27
2 changed files with 3 additions and 3 deletions

View File

@ -34,7 +34,7 @@ class TestCapabilities(base.BaseTestCase):
# Disappointingly, ffi.cast(type, 1) != ffi.cast(type, 1) # Disappointingly, ffi.cast(type, 1) != ffi.cast(type, 1)
# so can't just use assert_called_once_with :-( # so can't just use assert_called_once_with :-(
self.assertEqual(1, mock_prctl.call_count) self.assertEqual(1, mock_prctl.call_count)
self.assertItemsEqual( self.assertCountEqual(
[8, 1], # [PR_SET_KEEPCAPS, true] [8, 1], # [PR_SET_KEEPCAPS, true]
[int(x) for x in mock_prctl.call_args[0]]) [int(x) for x in mock_prctl.call_args[0]])
@ -81,7 +81,7 @@ class TestCapabilities(base.BaseTestCase):
return 0 return 0
mock_capget.side_effect = impl mock_capget.side_effect = impl
self.assertItemsEqual( self.assertCountEqual(
([17, 24, 49], ([17, 24, 49],
[8, 10, 35, 56], [8, 10, 35, 56],
[24, 31, 40]), [24, 31, 40]),

View File

@ -165,7 +165,7 @@ class DaemonTest(base.BaseTestCase):
mock_setgid.assert_called_once_with(84) mock_setgid.assert_called_once_with(84)
mock_setgroups.assert_called_once_with([]) mock_setgroups.assert_called_once_with([])
self.assertItemsEqual( self.assertCountEqual(
[mock.call(True), mock.call(False)], [mock.call(True), mock.call(False)],
mock_keepcaps.mock_calls) mock_keepcaps.mock_calls)