Skip to contentSkip to conversation

tests/avocado: Replace assertEquals() for Python 3.12 compatibility

PATCH In review Thomas Huth 2 participants 4 messages Nov 14, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/avocado: Replace assertEquals() for Python 3.12 compatibility

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

---
 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 | 96 ++++++++++++-------------
 5 files changed, 52 insertions(+), 52 deletions(-)
docs/devel/testing.rst +1 -1
index fef64accc1..87ed30af22 100644
@@ -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.
tests/avocado/cpu_queries.py +1 -1
index 86c2d5c92d..d3faa14720 100644
@@ -32,4 +32,4 @@ def test(self):
             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'])
tests/avocado/empty_cpu_model.py +1 -1
index 22f504418d..d906ef3d3c 100644
@@ -15,5 +15,5 @@ def test(self):
         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')
tests/avocado/pc_cpu_hotplug_props.py +1 -1
index b56f51d02a..4bd3e02665 100644
@@ -32,4 +32,4 @@ def test_no_die_id(self):
         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)
tests/avocado/x86_cpu_model_versions.py +48 -48

142 lines not on this page · raw message

Signature · 1 line
2.41.0
Reviewed-by on v1 1/1
#1 lore raw

Hi Thomas,

Quoted 2 lines · Thomas Huth

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

From this list I see assertEquals() has been deprecated in 3.2, along with assertRegexpMatches(). No warning for this single use?

tests/avocado/version.py:25: self.assertRegexpMatches(res, r'^(\d+\.\d+\.\d)')

Otherwise,

Quoted 8 lines
---
  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 | 96 ++++++++++++-------------
  5 files changed, 52 insertions(+), 52 deletions(-)
#2 lore raw
Quoted 6 lines · Philippe Mathieu-Daudé

Hi Thomas,

Quoted 2 lines · Thomas Huth

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

Quoted 7 lines

From this list I see assertEquals() has been deprecated in 3.2, along
with assertRegexpMatches(). No warning for this single use?

tests/avocado/version.py:25:        self.assertRegexpMatches(res, r'^(\d+\.\d+\.\d)')

Otherwise,

Thanks!

I still cannot run all avocado tests yet, so I didn't notice this problem yet. But you're right, if I only run this test manually, it also fails. Care to send a patch, or want me to include it in my patch?

Anyway, I'm seeing also failures here:

tests/avocado/replay_kernel.py:ReplayKernelNormal.test_x86_64_pc: INTERRUPTED tests/avocado/reverse_debugging.py:ReverseDebugging_ppc64.test_ppc64_pseries: INTERRUPTED tests/avocado/reverse_debugging.py:ReverseDebugging_ppc64.test_ppc64_powernv: ERROR

Are these still working for you?
(IIRC at least the replay_kernel test was also failing for me before I upgraded to Fedora 39, so it's likely not related to the new Python version)

Thomas

#3 lore raw
Quoted 12 lines · Thomas Huth
Quoted 11 lines · Philippe Mathieu-Daudé

Hi Thomas,

Quoted 2 lines · Thomas Huth

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

 From this list I see assertEquals() has been deprecated in 3.2, along with assertRegexpMatches(). No warning for this single use?

tests/avocado/version.py:25:        self.assertRegexpMatches(res, r'^(\d+\.\d+\.\d)')

Quoted 7 lines
Quoted 2 lines

Otherwise,

Thanks!

I still cannot run all avocado tests yet, so I didn't notice this problem yet.

At least you can run *some* tests :>

FYI macOS users still can't run QEMU's Avocado test suite. Personally I run it somewhere in a cloud machine.

Quoted 2 lines

But you're right, if I only run this test manually, it also fails. Care to send a patch, or want me to include it in my patch?

OK I'll send.

Quoted 5 lines

Anyway, I'm seeing also failures here:

 tests/avocado/replay_kernel.py:ReplayKernelNormal.test_x86_64_pc:
INTERRUPTED
 tests/avocado/reverse_debugging.py:ReverseDebugging_ppc64.test_ppc64_pseries: INTERRUPTED

Sometimes due to timeout.

Quoted 1 line

 tests/avocado/reverse_debugging.py:ReverseDebugging_ppc64.test_ppc64_powernv: ERROR

This one is concerning.

Quoted 4 lines

Are these still working for you?
(IIRC at least the replay_kernel test was also failing for me before I upgraded to Fedora 39, so it's likely not related to the new Python version)

Regards,

Phil.