Skip to content

Commit 737bc9f

Browse files
authored
[lldb] Replace assertRegexpMatches with assertRegex (NFC) (llvm#82074)
assertRegexpMatches is a deprecated alias for assertRegex and has been removed in Python 3.12. This wasn't an issue previously because we used a vendored version of the unittest module. Now that we use the built-in version this gets updated together with the Python version used to run the test suite.
1 parent 0bf4f82 commit 737bc9f

File tree

8 files changed

+28
-30
lines changed

8 files changed

+28
-30
lines changed

lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,13 @@ def continue_to_exception_breakpoint(self, filter_label):
249249
def continue_to_exit(self, exitCode=0):
250250
self.dap_server.request_continue()
251251
stopped_events = self.dap_server.wait_for_stopped()
252-
self.assertEquals(
252+
self.assertEqual(
253253
len(stopped_events), 1, "stopped_events = {}".format(stopped_events)
254254
)
255-
self.assertEquals(
255+
self.assertEqual(
256256
stopped_events[0]["event"], "exited", "make sure program ran to completion"
257257
)
258-
self.assertEquals(
258+
self.assertEqual(
259259
stopped_events[0]["body"]["exitCode"],
260260
exitCode,
261261
"exitCode == %i" % (exitCode),

lldb/test/API/functionalities/memory-region/TestMemoryRegion.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Test the 'memory region' command.
33
"""
44

5-
65
import lldb
76
from lldbsuite.test.decorators import *
87
from lldbsuite.test.lldbtest import *
@@ -62,7 +61,7 @@ def test_command(self):
6261
# We allow --all or an address argument, not both
6362
interp.HandleCommand("memory region --all 0", result)
6463
self.assertFalse(result.Succeeded())
65-
self.assertRegexpMatches(
64+
self.assertRegex(
6665
result.GetError(),
6766
'The "--all" option cannot be used when an address argument is given',
6867
)
@@ -81,7 +80,7 @@ def test_command(self):
8180
# Now let's print the memory region starting at 0 which should always work.
8281
interp.HandleCommand("memory region 0x0", result)
8382
self.assertTrue(result.Succeeded())
84-
self.assertRegexpMatches(result.GetOutput(), "\\[0x0+-")
83+
self.assertRegex(result.GetOutput(), "\\[0x0+-")
8584
all_regions += result.GetOutput()
8685

8786
# Keep printing memory regions until we printed all of them.
@@ -94,7 +93,7 @@ def test_command(self):
9493
# Now that we reached the end, 'memory region' should again print the usage.
9594
interp.HandleCommand("memory region", result)
9695
self.assertFalse(result.Succeeded())
97-
self.assertRegexpMatches(
96+
self.assertRegex(
9897
result.GetError(),
9998
"Usage: memory region <address\-expression> \(or \-\-all\)",
10099
)

lldb/test/API/functionalities/wrong_commands/TestWrongCommands.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Test how lldb reacts to wrong commands
33
"""
44

5-
65
import lldb
76
from lldbsuite.test.decorators import *
87
from lldbsuite.test.lldbtest import *
@@ -18,11 +17,9 @@ def test_ambiguous_command(self):
1817

1918
command_interpreter.HandleCommand("g", result)
2019
self.assertFalse(result.Succeeded())
21-
self.assertRegexpMatches(
22-
result.GetError(), "Ambiguous command 'g'. Possible matches:"
23-
)
24-
self.assertRegexpMatches(result.GetError(), "gui")
25-
self.assertRegexpMatches(result.GetError(), "gdb-remote")
20+
self.assertRegex(result.GetError(), "Ambiguous command 'g'. Possible matches:")
21+
self.assertRegex(result.GetError(), "gui")
22+
self.assertRegex(result.GetError(), "gdb-remote")
2623
self.assertEqual(1, result.GetError().count("gdb-remote"))
2724

2825
@no_debug_info_test

lldb/test/API/linux/aarch64/tagged_memory_access/TestAArch64LinuxTaggedMemoryAccess.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
always enables.
77
"""
88

9-
109
import lldb
1110
from lldbsuite.test.decorators import *
1211
from lldbsuite.test.lldbtest import *
@@ -83,7 +82,7 @@ def test_tagged_memory_find(self):
8382
out = self.res.GetOutput()
8483
# memory find does not fail when it doesn't find the data.
8584
# First check we actually got something.
86-
self.assertRegexpMatches(out, "data found at location: 0x[0-9A-Fa-f]+")
85+
self.assertRegex(out, "data found at location: 0x[0-9A-Fa-f]+")
8786
# Then that the location found does not display the tag bits.
8887
self.assertNotRegexpMatches(
8988
out, "data found at location: 0x(34|56)[0-9A-Fa-f]+"

lldb/test/API/linux/aarch64/tagged_memory_region/TestAArch64LinuxTaggedMemoryRegion.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
non address bits from addresses before lookup.
44
"""
55

6-
76
import lldb
87
from lldbsuite.test.decorators import *
98
from lldbsuite.test.lldbtest import *
@@ -57,7 +56,7 @@ def test_mte_regions(self):
5756
if result.Succeeded():
5857
repeats += 1
5958
else:
60-
self.assertRegexpMatches(result.GetError(), "Usage: memory region")
59+
self.assertRegex(result.GetError(), "Usage: memory region")
6160
break
6261

6362
# This time repeat until we get the last region. At that

lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
class TestDAP_evaluate(lldbdap_testcase.DAPTestCaseBase):
1515
def assertEvaluate(self, expression, regex):
16-
self.assertRegexpMatches(
16+
self.assertRegex(
1717
self.dap_server.request_evaluate(expression, context=self.context)["body"][
1818
"result"
1919
],
@@ -78,9 +78,11 @@ def run_test_evaluate_expressions(
7878
else:
7979
self.assertEvaluate(
8080
"struct1",
81-
re.escape("{foo:15}")
82-
if enableAutoVariableSummaries
83-
else "my_struct @ 0x",
81+
(
82+
re.escape("{foo:15}")
83+
if enableAutoVariableSummaries
84+
else "my_struct @ 0x"
85+
),
8486
)
8587
self.assertEvaluate(
8688
"struct2", "0x.* {foo:16}" if enableAutoVariableSummaries else "0x.*"
@@ -127,9 +129,11 @@ def run_test_evaluate_expressions(
127129
else:
128130
self.assertEvaluate(
129131
"struct1",
130-
re.escape("{foo:15}")
131-
if enableAutoVariableSummaries
132-
else "my_struct @ 0x",
132+
(
133+
re.escape("{foo:15}")
134+
if enableAutoVariableSummaries
135+
else "my_struct @ 0x"
136+
),
133137
)
134138
self.assertEvaluate("struct1.foo", "15")
135139
self.assertEvaluate("struct2->foo", "16")

lldb/test/API/tools/lldb-server/TestGdbRemoteLaunch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def test_launch_failure_via_vRun(self):
101101
)
102102
with open(exe_path, "ab") as exe_for_writing:
103103
context = self.expect_gdbremote_sequence()
104-
self.assertRegexpMatches(
104+
self.assertRegex(
105105
seven.unhexlify(context.get("msg")),
106106
r"(execve failed: Text file busy|The process cannot access the file because it is being used by another process.)",
107107
)

lldb/test/API/tools/lldb-server/TestGdbRemoteModuleInfo.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ def test_module_info(self):
4141

4242
context = self.expect_gdbremote_sequence()
4343
spec = context.get("spec")
44-
self.assertRegexpMatches(spec, '"file_path":".*"')
45-
self.assertRegexpMatches(spec, '"file_offset":\d+')
46-
self.assertRegexpMatches(spec, '"file_size":\d+')
47-
self.assertRegexpMatches(spec, '"triple":"\w*-\w*-.*"')
48-
self.assertRegexpMatches(spec, '"uuid":"[A-Fa-f0-9]+"')
44+
self.assertRegex(spec, '"file_path":".*"')
45+
self.assertRegex(spec, '"file_offset":\d+')
46+
self.assertRegex(spec, '"file_size":\d+')
47+
self.assertRegex(spec, '"triple":"\w*-\w*-.*"')
48+
self.assertRegex(spec, '"uuid":"[A-Fa-f0-9]+"')

0 commit comments

Comments
 (0)