From 861f724d03e1748cda1c5b9ec8457a368590cbd5 Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Tue, 14 Nov 2023 14:43:26 +0100 Subject: [PATCH] tests/avocado: Replace assertEquals() for Python 3.12 compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit assertEquals() has been removed in Python 3.12 and should be replaced by assertEqual(). See: https://docs.python.org/3.12/whatsnew/3.12.html#id3 Message-ID: <20231114134326.287242-1-thuth@redhat.com> Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Thomas Huth --- docs/devel/testing.rst | 2 +- tests/avocado/cpu_queries.py | 2 +- tests/avocado/empty_cpu_model.py | 2 +- tests/avocado/pc_cpu_hotplug_props.py | 2 +- tests/avocado/x86_cpu_model_versions.py | 97 +++++++++++++------------ 5 files changed, 53 insertions(+), 52 deletions(-) diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst index fef64accc1..87ed30af22 100644 --- a/docs/devel/testing.rst +++ b/docs/devel/testing.rst @@ -1077,7 +1077,7 @@ and hypothetical example follows: 'human-monitor-command', command_line='info version') - self.assertEquals(first_res, second_res, third_res) + self.assertEqual(first_res, second_res, third_res) At test "tear down", ``avocado_qemu.Test`` handles all the QEMUMachines shutdown. diff --git a/tests/avocado/cpu_queries.py b/tests/avocado/cpu_queries.py index 86c2d5c92d..d3faa14720 100644 --- a/tests/avocado/cpu_queries.py +++ b/tests/avocado/cpu_queries.py @@ -32,4 +32,4 @@ class QueryCPUModelExpansion(QemuSystemTest): model = {'name': c['name']} e = self.vm.cmd('query-cpu-model-expansion', model=model, type='full') - self.assertEquals(e['model']['name'], c['name']) + self.assertEqual(e['model']['name'], c['name']) diff --git a/tests/avocado/empty_cpu_model.py b/tests/avocado/empty_cpu_model.py index 22f504418d..d906ef3d3c 100644 --- a/tests/avocado/empty_cpu_model.py +++ b/tests/avocado/empty_cpu_model.py @@ -15,5 +15,5 @@ class EmptyCPUModel(QemuSystemTest): self.vm.set_qmp_monitor(enabled=False) self.vm.launch() self.vm.wait() - self.assertEquals(self.vm.exitcode(), 1, "QEMU exit code should be 1") + self.assertEqual(self.vm.exitcode(), 1, "QEMU exit code should be 1") self.assertRegex(self.vm.get_log(), r'-cpu option cannot be empty') diff --git a/tests/avocado/pc_cpu_hotplug_props.py b/tests/avocado/pc_cpu_hotplug_props.py index b56f51d02a..4bd3e02665 100644 --- a/tests/avocado/pc_cpu_hotplug_props.py +++ b/tests/avocado/pc_cpu_hotplug_props.py @@ -32,4 +32,4 @@ class OmittedCPUProps(QemuSystemTest): self.vm.add_args('-smp', '1,sockets=2,cores=2,threads=2,maxcpus=8') self.vm.add_args('-device', 'qemu64-x86_64-cpu,socket-id=1,core-id=0,thread-id=0') self.vm.launch() - self.assertEquals(len(self.vm.cmd('query-cpus-fast')), 2) + self.assertEqual(len(self.vm.cmd('query-cpus-fast')), 2) diff --git a/tests/avocado/x86_cpu_model_versions.py b/tests/avocado/x86_cpu_model_versions.py index 9e07b8a55d..11101e02b9 100644 --- a/tests/avocado/x86_cpu_model_versions.py +++ b/tests/avocado/x86_cpu_model_versions.py @@ -121,94 +121,95 @@ class X86CPUModelAliases(avocado_qemu.QemuSystemTest): self.assertFalse(cpus['Cascadelake-Server']['static'], 'unversioned Cascadelake-Server CPU model must not be static') - self.assertEquals(cpus['Cascadelake-Server'].get('alias-of'), 'Cascadelake-Server-v1', - 'Cascadelake-Server must be an alias of Cascadelake-Server-v1') + self.assertEqual(cpus['Cascadelake-Server'].get('alias-of'), + 'Cascadelake-Server-v1', + 'Cascadelake-Server must be an alias of Cascadelake-Server-v1') self.assertNotIn('alias-of', cpus['Cascadelake-Server-v1'], 'Cascadelake-Server-v1 must not be an alias') self.assertFalse(cpus['qemu64']['static'], 'unversioned qemu64 CPU model must not be static') - self.assertEquals(cpus['qemu64'].get('alias-of'), 'qemu64-v1', - 'qemu64 must be an alias of qemu64-v1') + self.assertEqual(cpus['qemu64'].get('alias-of'), 'qemu64-v1', + 'qemu64 must be an alias of qemu64-v1') self.assertNotIn('alias-of', cpus['qemu64-v1'], 'qemu64-v1 must not be an alias') self.validate_variant_aliases(cpus) # On pc-*-4.1, -noTSX and -IBRS models should be aliases: - self.assertEquals(cpus["Haswell"].get('alias-of'), - "Haswell-v1", + self.assertEqual(cpus["Haswell"].get('alias-of'), + "Haswell-v1", "Haswell must be an alias") - self.assertEquals(cpus["Haswell-noTSX"].get('alias-of'), - "Haswell-v2", + self.assertEqual(cpus["Haswell-noTSX"].get('alias-of'), + "Haswell-v2", "Haswell-noTSX must be an alias") - self.assertEquals(cpus["Haswell-IBRS"].get('alias-of'), - "Haswell-v3", + self.assertEqual(cpus["Haswell-IBRS"].get('alias-of'), + "Haswell-v3", "Haswell-IBRS must be an alias") - self.assertEquals(cpus["Haswell-noTSX-IBRS"].get('alias-of'), - "Haswell-v4", + self.assertEqual(cpus["Haswell-noTSX-IBRS"].get('alias-of'), + "Haswell-v4", "Haswell-noTSX-IBRS must be an alias") - self.assertEquals(cpus["Broadwell"].get('alias-of'), - "Broadwell-v1", + self.assertEqual(cpus["Broadwell"].get('alias-of'), + "Broadwell-v1", "Broadwell must be an alias") - self.assertEquals(cpus["Broadwell-noTSX"].get('alias-of'), - "Broadwell-v2", + self.assertEqual(cpus["Broadwell-noTSX"].get('alias-of'), + "Broadwell-v2", "Broadwell-noTSX must be an alias") - self.assertEquals(cpus["Broadwell-IBRS"].get('alias-of'), - "Broadwell-v3", + self.assertEqual(cpus["Broadwell-IBRS"].get('alias-of'), + "Broadwell-v3", "Broadwell-IBRS must be an alias") - self.assertEquals(cpus["Broadwell-noTSX-IBRS"].get('alias-of'), - "Broadwell-v4", + self.assertEqual(cpus["Broadwell-noTSX-IBRS"].get('alias-of'), + "Broadwell-v4", "Broadwell-noTSX-IBRS must be an alias") - self.assertEquals(cpus["Nehalem"].get('alias-of'), - "Nehalem-v1", + self.assertEqual(cpus["Nehalem"].get('alias-of'), + "Nehalem-v1", "Nehalem must be an alias") - self.assertEquals(cpus["Nehalem-IBRS"].get('alias-of'), - "Nehalem-v2", + self.assertEqual(cpus["Nehalem-IBRS"].get('alias-of'), + "Nehalem-v2", "Nehalem-IBRS must be an alias") - self.assertEquals(cpus["Westmere"].get('alias-of'), - "Westmere-v1", + self.assertEqual(cpus["Westmere"].get('alias-of'), + "Westmere-v1", "Westmere must be an alias") - self.assertEquals(cpus["Westmere-IBRS"].get('alias-of'), - "Westmere-v2", + self.assertEqual(cpus["Westmere-IBRS"].get('alias-of'), + "Westmere-v2", "Westmere-IBRS must be an alias") - self.assertEquals(cpus["SandyBridge"].get('alias-of'), - "SandyBridge-v1", + self.assertEqual(cpus["SandyBridge"].get('alias-of'), + "SandyBridge-v1", "SandyBridge must be an alias") - self.assertEquals(cpus["SandyBridge-IBRS"].get('alias-of'), - "SandyBridge-v2", + self.assertEqual(cpus["SandyBridge-IBRS"].get('alias-of'), + "SandyBridge-v2", "SandyBridge-IBRS must be an alias") - self.assertEquals(cpus["IvyBridge"].get('alias-of'), - "IvyBridge-v1", + self.assertEqual(cpus["IvyBridge"].get('alias-of'), + "IvyBridge-v1", "IvyBridge must be an alias") - self.assertEquals(cpus["IvyBridge-IBRS"].get('alias-of'), - "IvyBridge-v2", + self.assertEqual(cpus["IvyBridge-IBRS"].get('alias-of'), + "IvyBridge-v2", "IvyBridge-IBRS must be an alias") - self.assertEquals(cpus["Skylake-Client"].get('alias-of'), - "Skylake-Client-v1", + self.assertEqual(cpus["Skylake-Client"].get('alias-of'), + "Skylake-Client-v1", "Skylake-Client must be an alias") - self.assertEquals(cpus["Skylake-Client-IBRS"].get('alias-of'), - "Skylake-Client-v2", + self.assertEqual(cpus["Skylake-Client-IBRS"].get('alias-of'), + "Skylake-Client-v2", "Skylake-Client-IBRS must be an alias") - self.assertEquals(cpus["Skylake-Server"].get('alias-of'), - "Skylake-Server-v1", + self.assertEqual(cpus["Skylake-Server"].get('alias-of'), + "Skylake-Server-v1", "Skylake-Server must be an alias") - self.assertEquals(cpus["Skylake-Server-IBRS"].get('alias-of'), - "Skylake-Server-v2", + self.assertEqual(cpus["Skylake-Server-IBRS"].get('alias-of'), + "Skylake-Server-v2", "Skylake-Server-IBRS must be an alias") - self.assertEquals(cpus["EPYC"].get('alias-of'), - "EPYC-v1", + self.assertEqual(cpus["EPYC"].get('alias-of'), + "EPYC-v1", "EPYC must be an alias") - self.assertEquals(cpus["EPYC-IBPB"].get('alias-of'), - "EPYC-v2", + self.assertEqual(cpus["EPYC-IBPB"].get('alias-of'), + "EPYC-v2", "EPYC-IBPB must be an alias") self.validate_aliases(cpus)