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: Id2be00858df975e3ee6f8e12f7650e936d99d46b
This commit is contained in:
gugug 2020-07-12 11:21:20 +08:00
parent 111f3ca79f
commit ee7de7c839
2 changed files with 4 additions and 4 deletions

View File

@ -1129,7 +1129,7 @@ class TestUploadOnlyExisting(TestPluginV1):
self.cmd.take_action(parsed_args)
# ensure check_file_exists has not been called
self.assertItemsEqual(
self.assertCountEqual(
self.cmd.adapter.check_file_exists.call_args_list,
[mock.call(self.cmd.adapter, './ironic-python-agent.initramfs'),
mock.call(self.cmd.adapter, './ironic-python-agent.kernel')])
@ -1194,7 +1194,7 @@ class TestUploadOnlyExisting(TestPluginV1):
self.cmd.take_action(parsed_args)
# ensure check_file_exists has been called just with ipa
self.assertItemsEqual(
self.assertCountEqual(
self.cmd.adapter.check_file_exists.call_args_list,
[mock.call(self.cmd.adapter, './ironic-python-agent.initramfs'),
mock.call(self.cmd.adapter, './ironic-python-agent.kernel')]
@ -1226,7 +1226,7 @@ class TestUploadOnlyExisting(TestPluginV1):
self.cmd.take_action(parsed_args)
# ensure check_file_exists has been called just with ipa
self.assertItemsEqual(
self.assertCountEqual(
self.cmd.adapter.check_file_exists.call_args_list,
[mock.call(self.cmd.adapter, './overcloud-full.qcow2')])

View File

@ -77,7 +77,7 @@ class TestMinionInstall(TestPluginV1):
dry_run=True, force_stack_update=False, no_validations=True,
verbose_level=1)
mock_usercheck.assert_called_once()
self.assertItemsEqual(mock_subprocess.call_args_list, [])
self.assertCountEqual(mock_subprocess.call_args_list, [])
class TestMinionUpgrade(TestPluginV1):