Skip to content

Commit 80fcecb

Browse files
authored
[lldb] Replace assertEquals with assertEqual (NFC) (llvm#82073)
assertEquals is a deprecated alias for assertEqual 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 8443ce5 commit 80fcecb

File tree

111 files changed

+426
-426
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+426
-426
lines changed

lldb/packages/Python/lldbsuite/test/lldbutil.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -696,24 +696,24 @@ def check_breakpoint(
696696
test.assertTrue(bkpt.IsValid(), "Breakpoint is not valid.")
697697

698698
if expected_locations is not None:
699-
test.assertEquals(expected_locations, bkpt.GetNumLocations())
699+
test.assertEqual(expected_locations, bkpt.GetNumLocations())
700700

701701
if expected_resolved_count is not None:
702-
test.assertEquals(expected_resolved_count, bkpt.GetNumResolvedLocations())
702+
test.assertEqual(expected_resolved_count, bkpt.GetNumResolvedLocations())
703703
else:
704704
expected_resolved_count = bkpt.GetNumLocations()
705705
if location_id is None:
706-
test.assertEquals(expected_resolved_count, bkpt.GetNumResolvedLocations())
706+
test.assertEqual(expected_resolved_count, bkpt.GetNumResolvedLocations())
707707

708708
if expected_hit_count is not None:
709-
test.assertEquals(expected_hit_count, bkpt.GetHitCount())
709+
test.assertEqual(expected_hit_count, bkpt.GetHitCount())
710710

711711
if location_id is not None:
712712
loc_bkpt = bkpt.FindLocationByID(location_id)
713713
test.assertTrue(loc_bkpt.IsValid(), "Breakpoint location is not valid.")
714-
test.assertEquals(loc_bkpt.IsResolved(), expected_location_resolved)
714+
test.assertEqual(loc_bkpt.IsResolved(), expected_location_resolved)
715715
if expected_location_hit_count is not None:
716-
test.assertEquals(expected_location_hit_count, loc_bkpt.GetHitCount())
716+
test.assertEqual(expected_location_hit_count, loc_bkpt.GetHitCount())
717717

718718

719719
# ==================================================

lldb/test/API/commands/disassemble/basic/TestFrameDisassemble.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def frame_disassemble_test(self):
4848
)
4949

5050
# The hit count for the breakpoint should be 1.
51-
self.assertEquals(breakpoint.GetHitCount(), 1)
51+
self.assertEqual(breakpoint.GetHitCount(), 1)
5252

5353
frame = threads[0].GetFrameAtIndex(0)
5454
disassembly = frame.Disassemble()

lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def call_function(self):
7575
value = frame.EvaluateExpression("call_me (%d)" % (num_sigchld), options)
7676
self.assertTrue(value.IsValid())
7777
self.assertSuccess(value.GetError())
78-
self.assertEquals(value.GetValueAsSigned(-1), num_sigchld)
78+
self.assertEqual(value.GetValueAsSigned(-1), num_sigchld)
7979

8080
self.check_after_call(num_sigchld)
8181

@@ -92,7 +92,7 @@ def call_function(self):
9292

9393
self.assertTrue(value.IsValid())
9494
self.assertSuccess(value.GetError())
95-
self.assertEquals(value.GetValueAsSigned(-1), num_sigchld)
95+
self.assertEqual(value.GetValueAsSigned(-1), num_sigchld)
9696
self.check_after_call(num_sigchld)
9797

9898
# Now set the signal to print but not stop and make sure that calling
@@ -103,7 +103,7 @@ def call_function(self):
103103

104104
self.assertTrue(value.IsValid())
105105
self.assertSuccess(value.GetError())
106-
self.assertEquals(value.GetValueAsSigned(-1), num_sigchld)
106+
self.assertEqual(value.GetValueAsSigned(-1), num_sigchld)
107107
self.check_after_call(num_sigchld)
108108

109109
# Now set this unwind on error to false, and make sure that we still
@@ -113,7 +113,7 @@ def call_function(self):
113113

114114
self.assertTrue(value.IsValid())
115115
self.assertSuccess(value.GetError())
116-
self.assertEquals(value.GetValueAsSigned(-1), num_sigchld)
116+
self.assertEqual(value.GetValueAsSigned(-1), num_sigchld)
117117
self.check_after_call(num_sigchld)
118118

119119
# Okay, now set UnwindOnError to true, and then make the signal behavior to stop

lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def call_function(self):
4646

4747
value = frame.EvaluateExpression("[my_class callMeIThrow]", options)
4848
self.assertTrue(value.IsValid())
49-
self.assertEquals(value.GetError().Success(), False)
49+
self.assertEqual(value.GetError().Success(), False)
5050

5151
self.check_after_call()
5252

@@ -86,7 +86,7 @@ def call_function(self):
8686
value = frame.EvaluateExpression("[my_class iCatchMyself]", options)
8787
self.assertTrue(value.IsValid())
8888
self.assertSuccess(value.GetError())
89-
self.assertEquals(value.GetValueAsUnsigned(), 57)
89+
self.assertEqual(value.GetValueAsUnsigned(), 57)
9090
self.check_after_call()
9191
options.SetTrapExceptions(True)
9292

lldb/test/API/commands/expression/completion/TestExprCompletion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ def assume_no_completions(self, str_input, cursor_pos=None):
305305
for m in match_strings:
306306
available_completions.append(m)
307307

308-
self.assertEquals(
308+
self.assertEqual(
309309
num_matches,
310310
0,
311311
"Got matches, but didn't expect any: " + str(available_completions),

lldb/test/API/commands/expression/fixits/TestFixIts.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_with_target(self):
4646
value = frame.EvaluateExpression("my_pointer.first", options)
4747
self.assertTrue(value.IsValid())
4848
self.assertSuccess(value.GetError())
49-
self.assertEquals(value.GetValueAsUnsigned(), 10)
49+
self.assertEqual(value.GetValueAsUnsigned(), 10)
5050

5151
# Try with one error in a top-level expression.
5252
# The Fix-It changes "ptr.m" to "ptr->m".
@@ -56,22 +56,22 @@ def test_with_target(self):
5656
# unknown error . If a parsing error would have happened we
5757
# would get a different error kind, so let's check the error
5858
# kind here.
59-
self.assertEquals(value.GetError().GetCString(), "unknown error")
59+
self.assertEqual(value.GetError().GetCString(), "unknown error")
6060

6161
# Try with two errors:
6262
two_error_expression = "my_pointer.second->a"
6363
value = frame.EvaluateExpression(two_error_expression, options)
6464
self.assertTrue(value.IsValid())
6565
self.assertSuccess(value.GetError())
66-
self.assertEquals(value.GetValueAsUnsigned(), 20)
66+
self.assertEqual(value.GetValueAsUnsigned(), 20)
6767

6868
# Try a Fix-It that is stored in the 'note:' diagnostic of an error.
6969
# The Fix-It here is adding parantheses around the ToStr parameters.
7070
fixit_in_note_expr = "#define ToStr(x) #x\nToStr(0 {, })"
7171
value = frame.EvaluateExpression(fixit_in_note_expr, options)
7272
self.assertTrue(value.IsValid())
7373
self.assertSuccess(value.GetError())
74-
self.assertEquals(value.GetSummary(), '"(0 {, })"')
74+
self.assertEqual(value.GetSummary(), '"(0 {, })"')
7575

7676
# Now turn off the fixits, and the expression should fail:
7777
options.SetAutoApplyFixIts(False)
@@ -178,7 +178,7 @@ def test_with_multiple_retries(self):
178178
multiple_runs_options.SetRetriesWithFixIts(2)
179179
value = frame.EvaluateExpression(two_runs_expr, multiple_runs_options)
180180
# This error signals success for top level expressions.
181-
self.assertEquals(value.GetError().GetCString(), "unknown error")
181+
self.assertEqual(value.GetError().GetCString(), "unknown error")
182182

183183
# Test that the code above compiles to the right thing.
184184
self.expect_expr("test_X(1)", result_type="int", result_value="123")

lldb/test/API/commands/expression/save_jit_objects/TestSaveJITObjects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_save_jit_objects(self):
3737

3838
self.cleanJITFiles()
3939
frame.EvaluateExpression("(void*)malloc(0x1)")
40-
self.assertEquals(
40+
self.assertEqual(
4141
self.countJITFiles(), 0, "No files emitted with save-jit-objects-dir empty"
4242
)
4343

lldb/test/API/commands/expression/test/TestExprs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def test_evaluate_expression_python(self):
124124
)
125125

126126
# We should be stopped on the breakpoint with a hit count of 1.
127-
self.assertEquals(breakpoint.GetHitCount(), 1, BREAKPOINT_HIT_ONCE)
127+
self.assertEqual(breakpoint.GetHitCount(), 1, BREAKPOINT_HIT_ONCE)
128128

129129
#
130130
# Use Python API to evaluate expressions while stopped in a stack frame.
@@ -169,15 +169,15 @@ def test_evaluate_expression_python(self):
169169
self.expect(
170170
"expression -i true -- a_function_to_call()", substrs=["(int) $", " 1"]
171171
)
172-
self.assertEquals(callee_break.GetHitCount(), 1)
172+
self.assertEqual(callee_break.GetHitCount(), 1)
173173

174174
# Now try ignoring breakpoints using the SB API's:
175175
options = lldb.SBExpressionOptions()
176176
options.SetIgnoreBreakpoints(True)
177177
value = frame.EvaluateExpression("a_function_to_call()", options)
178178
self.assertTrue(value.IsValid())
179-
self.assertEquals(value.GetValueAsSigned(0), 2)
180-
self.assertEquals(callee_break.GetHitCount(), 2)
179+
self.assertEqual(value.GetValueAsSigned(0), 2)
180+
self.assertEqual(callee_break.GetHitCount(), 2)
181181

182182
# rdar://problem/8686536
183183
# CommandInterpreter::HandleCommand is stripping \'s from input for

lldb/test/API/commands/expression/timeout/TestCallWithTimeout.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test(self):
4646
return_value = interp.HandleCommand(
4747
"expr -t 100 -u true -- wait_a_while(1000000)", result
4848
)
49-
self.assertEquals(return_value, lldb.eReturnStatusFailed)
49+
self.assertEqual(return_value, lldb.eReturnStatusFailed)
5050

5151
# Okay, now do it again with long enough time outs:
5252

@@ -63,7 +63,7 @@ def test(self):
6363
return_value = interp.HandleCommand(
6464
"expr -t 1000000 -u true -- wait_a_while(1000)", result
6565
)
66-
self.assertEquals(return_value, lldb.eReturnStatusSuccessFinishResult)
66+
self.assertEqual(return_value, lldb.eReturnStatusSuccessFinishResult)
6767

6868
# Finally set the one thread timeout and make sure that doesn't change
6969
# things much:

lldb/test/API/commands/expression/unwind_expression/TestUnwindExpression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_conditional_bktp(self):
4242
main_frame = self.thread.GetFrameAtIndex(0)
4343
val = main_frame.EvaluateExpression("second_function(47)", options)
4444
self.assertSuccess(val.GetError(), "We did complete the execution.")
45-
self.assertEquals(47, val.GetValueAsSigned())
45+
self.assertEqual(47, val.GetValueAsSigned())
4646

4747
@add_test_categories(["pyapi"])
4848
@expectedFlakeyNetBSD

lldb/test/API/commands/frame/language/TestGuessLanguage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def do_test(self):
5959
)
6060

6161
# The hit count for the breakpoint should be 1.
62-
self.assertEquals(breakpoint.GetHitCount(), 1)
62+
self.assertEqual(breakpoint.GetHitCount(), 1)
6363

6464
thread = threads[0]
6565

lldb/test/API/commands/frame/var/TestFrameVar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def do_test(self):
5252
)
5353

5454
# The hit count for the breakpoint should be 1.
55-
self.assertEquals(breakpoint.GetHitCount(), 1)
55+
self.assertEqual(breakpoint.GetHitCount(), 1)
5656

5757
frame = threads[0].GetFrameAtIndex(0)
5858
command_result = lldb.SBCommandReturnObject()

lldb/test/API/commands/log/basic/TestLogging.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test_log_truncate(self):
6262
contents = f.read()
6363

6464
# check that it got removed
65-
self.assertEquals(contents.find("bacon"), -1)
65+
self.assertEqual(contents.find("bacon"), -1)
6666

6767
# Check that lldb can append to a log file
6868
def test_log_append(self):
@@ -79,7 +79,7 @@ def test_log_append(self):
7979
contents = f.read()
8080

8181
# check that it is still there
82-
self.assertEquals(contents.find("bacon"), 0)
82+
self.assertEqual(contents.find("bacon"), 0)
8383

8484
# Enable all log options and check that nothing crashes.
8585
@skipIfWindows

lldb/test/API/commands/memory/read/TestMemoryRead.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_memory_read(self):
5757
address = int(items[0], 0)
5858
argc = int(items[1], 0)
5959
self.assertGreater(address, 0)
60-
self.assertEquals(argc, 1)
60+
self.assertEqual(argc, 1)
6161

6262
# (lldb) memory read --format uint32_t[] --size 4 --count 4 `&argc`
6363
# 0x7fff5fbff9a0: {0x00000001}
@@ -130,7 +130,7 @@ def test_memory_read(self):
130130
# Check that we got back 4 0x0000 etc bytes
131131
for o in objects_read:
132132
self.assertEqual(len(o), expected_object_length)
133-
self.assertEquals(len(objects_read), 4)
133+
self.assertEqual(len(objects_read), 4)
134134

135135
def test_memory_read_file(self):
136136
self.build_run_stop()

lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ def test_step_over_read_watchpoint(self):
5353
lldb.eStopReasonWatchpoint,
5454
STOPPED_DUE_TO_WATCHPOINT,
5555
)
56-
self.assertEquals(thread.GetStopDescription(20), "watchpoint 1")
56+
self.assertEqual(thread.GetStopDescription(20), "watchpoint 1")
5757

5858
process.Continue()
5959
self.assertState(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED)
60-
self.assertEquals(thread.GetStopDescription(20), "step over")
60+
self.assertEqual(thread.GetStopDescription(20), "step over")
6161

6262
self.step_inst_for_watchpoint(1)
6363

@@ -95,11 +95,11 @@ def test_step_over_write_watchpoint(self):
9595
lldb.eStopReasonWatchpoint,
9696
STOPPED_DUE_TO_WATCHPOINT,
9797
)
98-
self.assertEquals(thread.GetStopDescription(20), "watchpoint 1")
98+
self.assertEqual(thread.GetStopDescription(20), "watchpoint 1")
9999

100100
process.Continue()
101101
self.assertState(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED)
102-
self.assertEquals(thread.GetStopDescription(20), "step over")
102+
self.assertEqual(thread.GetStopDescription(20), "step over")
103103

104104
self.step_inst_for_watchpoint(1)
105105

@@ -113,7 +113,7 @@ def step_inst_for_watchpoint(self, wp_id):
113113
self.assertFalse(watchpoint_hit, "Watchpoint already hit.")
114114
expected_stop_desc = "watchpoint %d" % wp_id
115115
actual_stop_desc = self.thread().GetStopDescription(20)
116-
self.assertEquals(
116+
self.assertEqual(
117117
actual_stop_desc, expected_stop_desc, "Watchpoint ID didn't match."
118118
)
119119
watchpoint_hit = True

lldb/test/API/driver/job_control/TestJobControl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def post_spawn():
2222
status = int(self.child.match[1])
2323

2424
self.assertTrue(os.WIFSTOPPED(status))
25-
self.assertEquals(os.WSTOPSIG(status), signal.SIGTSTP)
25+
self.assertEqual(os.WSTOPSIG(status), signal.SIGTSTP)
2626

2727
os.kill(self.lldb_pid, signal.SIGCONT)
2828

lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def address_breakpoints(self):
6464
)
6565

6666
# The hit count for the breakpoint should be 1.
67-
self.assertEquals(breakpoint.GetHitCount(), 1)
67+
self.assertEqual(breakpoint.GetHitCount(), 1)
6868

6969
process.Kill()
7070

@@ -82,4 +82,4 @@ def address_breakpoints(self):
8282

8383
# The hit count for the breakpoint should be 1, since we reset counts
8484
# for each run.
85-
self.assertEquals(breakpoint.GetHitCount(), 1)
85+
self.assertEqual(breakpoint.GetHitCount(), 1)

lldb/test/API/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def address_breakpoints(self):
4040
bkpt = target.BreakpointCreateByAddress(illegal_address)
4141
# Verify that breakpoint is not resolved.
4242
for bp_loc in bkpt:
43-
self.assertEquals(bp_loc.IsResolved(), False)
43+
self.assertEqual(bp_loc.IsResolved(), False)
4444
else:
4545
self.fail(
4646
"Could not find an illegal address at which to set a bad breakpoint."

lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,8 @@ def breakpoint_command_sequence(self):
361361
self.runCmd("run", RUN_SUCCEEDED)
362362

363363
# Check the value of canary variables.
364-
self.assertEquals("one liner was here", side_effect.one_liner)
365-
self.assertEquals("function was here", side_effect.bktptcmd)
364+
self.assertEqual("one liner was here", side_effect.one_liner)
365+
self.assertEqual("function was here", side_effect.bktptcmd)
366366

367367
# Finish the program.
368368
self.runCmd("process continue")
@@ -558,10 +558,10 @@ def get_source_map_json(self):
558558
return json.loads(stream.GetData())
559559

560560
def verify_source_map_entry_pair(self, entry, original, replacement):
561-
self.assertEquals(
561+
self.assertEqual(
562562
entry[0], original, "source map entry 'original' does not match"
563563
)
564-
self.assertEquals(
564+
self.assertEqual(
565565
entry[1], replacement, "source map entry 'replacement' does not match"
566566
)
567567

@@ -604,7 +604,7 @@ def test_breakpoints_auto_source_map_relative(self):
604604
# "./a/b/c/main.cpp".
605605

606606
source_map_json = self.get_source_map_json()
607-
self.assertEquals(
607+
self.assertEqual(
608608
len(source_map_json), 0, "source map should be empty initially"
609609
)
610610
self.verify_source_map_deduce_statistics(target, 0)
@@ -621,7 +621,7 @@ def test_breakpoints_auto_source_map_relative(self):
621621
)
622622

623623
source_map_json = self.get_source_map_json()
624-
self.assertEquals(len(source_map_json), 1, "source map should not be empty")
624+
self.assertEqual(len(source_map_json), 1, "source map should not be empty")
625625
self.verify_source_map_entry_pair(source_map_json[0], ".", "/x/y")
626626
self.verify_source_map_deduce_statistics(target, 1)
627627

@@ -640,7 +640,7 @@ def test_breakpoints_auto_source_map_relative(self):
640640
)
641641

642642
source_map_json = self.get_source_map_json()
643-
self.assertEquals(len(source_map_json), 0, "source map should not be deduced")
643+
self.assertEqual(len(source_map_json), 0, "source map should not be deduced")
644644

645645
def test_breakpoint_statistics_hitcount(self):
646646
"""Test breakpoints statistics have hitCount field."""

0 commit comments

Comments
 (0)