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: I9df3355ed619a66d33559366821b907db2950e65
This commit is contained in:
wu.chunyang 2020-09-14 11:28:18 +08:00 committed by Andrey Kurilin
parent 608163f525
commit 2304338982
1 changed files with 3 additions and 3 deletions

View File

@ -39,7 +39,7 @@ class AuthenticateTestCase(test.ScenarioTestCase):
# force glanceclient to actually make the API call, and this
# results in a bunch of call().__iter__() and call().__len__()
# calls that aren't matched if we use assert_has_calls().
self.assertItemsEqual(
self.assertCountEqual(
self.clients("glance").images.list.call_args_list,
[mock.call(name=mock.ANY)] * 5)
self._test_atomic_action_timer(scenario_inst.atomic_actions(),
@ -88,7 +88,7 @@ class AuthenticateTestCase(test.ScenarioTestCase):
def test_validate_heat(self):
scenario_inst = authenticate.ValidateHeat()
scenario_inst.run(5)
self.assertItemsEqual(
self.assertCountEqual(
self.clients("heat").stacks.list.call_args_list,
[mock.call(limit=0)] * 5)
self._test_atomic_action_timer(scenario_inst.atomic_actions(),
@ -97,7 +97,7 @@ class AuthenticateTestCase(test.ScenarioTestCase):
def test_validate_monasca(self):
scenario_inst = authenticate.ValidateMonasca()
scenario_inst.run(5)
self.assertItemsEqual(
self.assertCountEqual(
self.clients("monasca").metrics.list.call_args_list,
[mock.call(limit=0)] * 5)
self._test_atomic_action_timer(scenario_inst.atomic_actions(),