Skip to contentSkip to conversation

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

PATCH In review Philippe Mathieu-Daudé 2 participants 2 messages Nov 14, 2023

lore
Share & tools
lore
#0 lore raw

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

assertRegexpMatches() has been removed in Python 3.12 and should be replaced by assertRegex(). See: https://docs.python.org/3.12/whatsnew/3.12.html#id3

---
 docs/devel/testing.rst   | 2 +-
 tests/avocado/version.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
docs/devel/testing.rst +1 -1
index fef64accc1..0af8f32fa3 100644
@@ -1016,7 +1016,7 @@ class.  Here's a simple usage example:
           self.vm.launch()
           res = self.vm.cmd('human-monitor-command',
                             command_line='info version')
-          self.assertRegexpMatches(res, r'^(\d+\.\d+\.\d)')
+          self.assertRegex(res, r'^(\d+\.\d+\.\d)')
 
 To execute your test, run:
 
tests/avocado/version.py +1 -1
index 93ffdf3d97..c6139568a1 100644
@@ -22,4 +22,4 @@ def test_qmp_human_info_version(self):
         self.vm.launch()
         res = self.vm.cmd('human-monitor-command',
                           command_line='info version')
-        self.assertRegexpMatches(res, r'^(\d+\.\d+\.\d)')
+        self.assertRegex(res, r'^(\d+\.\d+\.\d)')
Signature · 1 line
2.41.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 28 lines · Philippe Mathieu-Daudé

assertRegexpMatches() has been removed in Python 3.12 and should be replaced by assertRegex(). See: https://docs.python.org/3.12/whatsnew/3.12.html#id3

---
  docs/devel/testing.rst   | 2 +-
  tests/avocado/version.py | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
docs/devel/testing.rst +1 -1
index fef64accc1..0af8f32fa3 100644
@@ -1016,7 +1016,7 @@ class.  Here's a simple usage example:
            self.vm.launch()
            res = self.vm.cmd('human-monitor-command',
                              command_line='info version')
-          self.assertRegexpMatches(res, r'^(\d+\.\d+\.\d)')
+          self.assertRegex(res, r'^(\d+\.\d+\.\d)')
 
  To execute your test, run:
 
tests/avocado/version.py +0 -0
index 93ffdf3d97..c6139568a1 100644

tests/avocado/version.py def test_qmp_human_info_version(self): · line 25

Quoted 5 lines
tests/avocado/version.py +1 -1
@@ -22,4 +22,4 @@ def test_qmp_human_info_version(self):
          self.vm.launch()
          res = self.vm.cmd('human-monitor-command',
                            command_line='info version')
-        self.assertRegexpMatches(res, r'^(\d+\.\d+\.\d)')
+        self.assertRegex(res, r'^(\d+\.\d+\.\d)')