-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[lldb] Replace assertEquals with assertEqual (NFC) #82073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
@llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) ChangesassertEquals 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. Patch is 165.12 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/82073.diff 111 Files Affected:
diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index 506c213639e092..58eb37fd742d73 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -696,24 +696,24 @@ def check_breakpoint(
test.assertTrue(bkpt.IsValid(), "Breakpoint is not valid.")
if expected_locations is not None:
- test.assertEquals(expected_locations, bkpt.GetNumLocations())
+ test.assertEqual(expected_locations, bkpt.GetNumLocations())
if expected_resolved_count is not None:
- test.assertEquals(expected_resolved_count, bkpt.GetNumResolvedLocations())
+ test.assertEqual(expected_resolved_count, bkpt.GetNumResolvedLocations())
else:
expected_resolved_count = bkpt.GetNumLocations()
if location_id is None:
- test.assertEquals(expected_resolved_count, bkpt.GetNumResolvedLocations())
+ test.assertEqual(expected_resolved_count, bkpt.GetNumResolvedLocations())
if expected_hit_count is not None:
- test.assertEquals(expected_hit_count, bkpt.GetHitCount())
+ test.assertEqual(expected_hit_count, bkpt.GetHitCount())
if location_id is not None:
loc_bkpt = bkpt.FindLocationByID(location_id)
test.assertTrue(loc_bkpt.IsValid(), "Breakpoint location is not valid.")
- test.assertEquals(loc_bkpt.IsResolved(), expected_location_resolved)
+ test.assertEqual(loc_bkpt.IsResolved(), expected_location_resolved)
if expected_location_hit_count is not None:
- test.assertEquals(expected_location_hit_count, loc_bkpt.GetHitCount())
+ test.assertEqual(expected_location_hit_count, loc_bkpt.GetHitCount())
# ==================================================
diff --git a/lldb/test/API/commands/disassemble/basic/TestFrameDisassemble.py b/lldb/test/API/commands/disassemble/basic/TestFrameDisassemble.py
index 0fd56a069d8940..0d324918d0658b 100644
--- a/lldb/test/API/commands/disassemble/basic/TestFrameDisassemble.py
+++ b/lldb/test/API/commands/disassemble/basic/TestFrameDisassemble.py
@@ -48,7 +48,7 @@ def frame_disassemble_test(self):
)
# The hit count for the breakpoint should be 1.
- self.assertEquals(breakpoint.GetHitCount(), 1)
+ self.assertEqual(breakpoint.GetHitCount(), 1)
frame = threads[0].GetFrameAtIndex(0)
disassembly = frame.Disassemble()
diff --git a/lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py b/lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py
index 220cd88bf194ec..214d890db3fe34 100644
--- a/lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py
+++ b/lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py
@@ -75,7 +75,7 @@ def call_function(self):
value = frame.EvaluateExpression("call_me (%d)" % (num_sigchld), options)
self.assertTrue(value.IsValid())
self.assertSuccess(value.GetError())
- self.assertEquals(value.GetValueAsSigned(-1), num_sigchld)
+ self.assertEqual(value.GetValueAsSigned(-1), num_sigchld)
self.check_after_call(num_sigchld)
@@ -92,7 +92,7 @@ def call_function(self):
self.assertTrue(value.IsValid())
self.assertSuccess(value.GetError())
- self.assertEquals(value.GetValueAsSigned(-1), num_sigchld)
+ self.assertEqual(value.GetValueAsSigned(-1), num_sigchld)
self.check_after_call(num_sigchld)
# Now set the signal to print but not stop and make sure that calling
@@ -103,7 +103,7 @@ def call_function(self):
self.assertTrue(value.IsValid())
self.assertSuccess(value.GetError())
- self.assertEquals(value.GetValueAsSigned(-1), num_sigchld)
+ self.assertEqual(value.GetValueAsSigned(-1), num_sigchld)
self.check_after_call(num_sigchld)
# Now set this unwind on error to false, and make sure that we still
@@ -113,7 +113,7 @@ def call_function(self):
self.assertTrue(value.IsValid())
self.assertSuccess(value.GetError())
- self.assertEquals(value.GetValueAsSigned(-1), num_sigchld)
+ self.assertEqual(value.GetValueAsSigned(-1), num_sigchld)
self.check_after_call(num_sigchld)
# Okay, now set UnwindOnError to true, and then make the signal behavior to stop
diff --git a/lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py b/lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py
index 9dce2529def019..8d524ad9e9b6fb 100644
--- a/lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py
+++ b/lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py
@@ -46,7 +46,7 @@ def call_function(self):
value = frame.EvaluateExpression("[my_class callMeIThrow]", options)
self.assertTrue(value.IsValid())
- self.assertEquals(value.GetError().Success(), False)
+ self.assertEqual(value.GetError().Success(), False)
self.check_after_call()
@@ -86,7 +86,7 @@ def call_function(self):
value = frame.EvaluateExpression("[my_class iCatchMyself]", options)
self.assertTrue(value.IsValid())
self.assertSuccess(value.GetError())
- self.assertEquals(value.GetValueAsUnsigned(), 57)
+ self.assertEqual(value.GetValueAsUnsigned(), 57)
self.check_after_call()
options.SetTrapExceptions(True)
diff --git a/lldb/test/API/commands/expression/completion/TestExprCompletion.py b/lldb/test/API/commands/expression/completion/TestExprCompletion.py
index ada818989c789a..c6a1e3c0f42275 100644
--- a/lldb/test/API/commands/expression/completion/TestExprCompletion.py
+++ b/lldb/test/API/commands/expression/completion/TestExprCompletion.py
@@ -305,7 +305,7 @@ def assume_no_completions(self, str_input, cursor_pos=None):
for m in match_strings:
available_completions.append(m)
- self.assertEquals(
+ self.assertEqual(
num_matches,
0,
"Got matches, but didn't expect any: " + str(available_completions),
diff --git a/lldb/test/API/commands/expression/fixits/TestFixIts.py b/lldb/test/API/commands/expression/fixits/TestFixIts.py
index 38b242838c828f..3289bc0c5c7e03 100644
--- a/lldb/test/API/commands/expression/fixits/TestFixIts.py
+++ b/lldb/test/API/commands/expression/fixits/TestFixIts.py
@@ -46,7 +46,7 @@ def test_with_target(self):
value = frame.EvaluateExpression("my_pointer.first", options)
self.assertTrue(value.IsValid())
self.assertSuccess(value.GetError())
- self.assertEquals(value.GetValueAsUnsigned(), 10)
+ self.assertEqual(value.GetValueAsUnsigned(), 10)
# Try with one error in a top-level expression.
# The Fix-It changes "ptr.m" to "ptr->m".
@@ -56,14 +56,14 @@ def test_with_target(self):
# unknown error . If a parsing error would have happened we
# would get a different error kind, so let's check the error
# kind here.
- self.assertEquals(value.GetError().GetCString(), "unknown error")
+ self.assertEqual(value.GetError().GetCString(), "unknown error")
# Try with two errors:
two_error_expression = "my_pointer.second->a"
value = frame.EvaluateExpression(two_error_expression, options)
self.assertTrue(value.IsValid())
self.assertSuccess(value.GetError())
- self.assertEquals(value.GetValueAsUnsigned(), 20)
+ self.assertEqual(value.GetValueAsUnsigned(), 20)
# Try a Fix-It that is stored in the 'note:' diagnostic of an error.
# The Fix-It here is adding parantheses around the ToStr parameters.
@@ -71,7 +71,7 @@ def test_with_target(self):
value = frame.EvaluateExpression(fixit_in_note_expr, options)
self.assertTrue(value.IsValid())
self.assertSuccess(value.GetError())
- self.assertEquals(value.GetSummary(), '"(0 {, })"')
+ self.assertEqual(value.GetSummary(), '"(0 {, })"')
# Now turn off the fixits, and the expression should fail:
options.SetAutoApplyFixIts(False)
@@ -178,7 +178,7 @@ def test_with_multiple_retries(self):
multiple_runs_options.SetRetriesWithFixIts(2)
value = frame.EvaluateExpression(two_runs_expr, multiple_runs_options)
# This error signals success for top level expressions.
- self.assertEquals(value.GetError().GetCString(), "unknown error")
+ self.assertEqual(value.GetError().GetCString(), "unknown error")
# Test that the code above compiles to the right thing.
self.expect_expr("test_X(1)", result_type="int", result_value="123")
diff --git a/lldb/test/API/commands/expression/save_jit_objects/TestSaveJITObjects.py b/lldb/test/API/commands/expression/save_jit_objects/TestSaveJITObjects.py
index 438b92cdc48462..aa125253763fdd 100644
--- a/lldb/test/API/commands/expression/save_jit_objects/TestSaveJITObjects.py
+++ b/lldb/test/API/commands/expression/save_jit_objects/TestSaveJITObjects.py
@@ -37,7 +37,7 @@ def test_save_jit_objects(self):
self.cleanJITFiles()
frame.EvaluateExpression("(void*)malloc(0x1)")
- self.assertEquals(
+ self.assertEqual(
self.countJITFiles(), 0, "No files emitted with save-jit-objects-dir empty"
)
diff --git a/lldb/test/API/commands/expression/test/TestExprs.py b/lldb/test/API/commands/expression/test/TestExprs.py
index 0e3d2e6cf41ffb..0e3215522ea6e8 100644
--- a/lldb/test/API/commands/expression/test/TestExprs.py
+++ b/lldb/test/API/commands/expression/test/TestExprs.py
@@ -124,7 +124,7 @@ def test_evaluate_expression_python(self):
)
# We should be stopped on the breakpoint with a hit count of 1.
- self.assertEquals(breakpoint.GetHitCount(), 1, BREAKPOINT_HIT_ONCE)
+ self.assertEqual(breakpoint.GetHitCount(), 1, BREAKPOINT_HIT_ONCE)
#
# Use Python API to evaluate expressions while stopped in a stack frame.
@@ -169,15 +169,15 @@ def test_evaluate_expression_python(self):
self.expect(
"expression -i true -- a_function_to_call()", substrs=["(int) $", " 1"]
)
- self.assertEquals(callee_break.GetHitCount(), 1)
+ self.assertEqual(callee_break.GetHitCount(), 1)
# Now try ignoring breakpoints using the SB API's:
options = lldb.SBExpressionOptions()
options.SetIgnoreBreakpoints(True)
value = frame.EvaluateExpression("a_function_to_call()", options)
self.assertTrue(value.IsValid())
- self.assertEquals(value.GetValueAsSigned(0), 2)
- self.assertEquals(callee_break.GetHitCount(), 2)
+ self.assertEqual(value.GetValueAsSigned(0), 2)
+ self.assertEqual(callee_break.GetHitCount(), 2)
# rdar://problem/8686536
# CommandInterpreter::HandleCommand is stripping \'s from input for
diff --git a/lldb/test/API/commands/expression/timeout/TestCallWithTimeout.py b/lldb/test/API/commands/expression/timeout/TestCallWithTimeout.py
index dc3d175b695b6b..2c48024c698337 100644
--- a/lldb/test/API/commands/expression/timeout/TestCallWithTimeout.py
+++ b/lldb/test/API/commands/expression/timeout/TestCallWithTimeout.py
@@ -46,7 +46,7 @@ def test(self):
return_value = interp.HandleCommand(
"expr -t 100 -u true -- wait_a_while(1000000)", result
)
- self.assertEquals(return_value, lldb.eReturnStatusFailed)
+ self.assertEqual(return_value, lldb.eReturnStatusFailed)
# Okay, now do it again with long enough time outs:
@@ -63,7 +63,7 @@ def test(self):
return_value = interp.HandleCommand(
"expr -t 1000000 -u true -- wait_a_while(1000)", result
)
- self.assertEquals(return_value, lldb.eReturnStatusSuccessFinishResult)
+ self.assertEqual(return_value, lldb.eReturnStatusSuccessFinishResult)
# Finally set the one thread timeout and make sure that doesn't change
# things much:
diff --git a/lldb/test/API/commands/expression/unwind_expression/TestUnwindExpression.py b/lldb/test/API/commands/expression/unwind_expression/TestUnwindExpression.py
index ca2ba37f883872..bb173c0584a46e 100644
--- a/lldb/test/API/commands/expression/unwind_expression/TestUnwindExpression.py
+++ b/lldb/test/API/commands/expression/unwind_expression/TestUnwindExpression.py
@@ -42,7 +42,7 @@ def test_conditional_bktp(self):
main_frame = self.thread.GetFrameAtIndex(0)
val = main_frame.EvaluateExpression("second_function(47)", options)
self.assertSuccess(val.GetError(), "We did complete the execution.")
- self.assertEquals(47, val.GetValueAsSigned())
+ self.assertEqual(47, val.GetValueAsSigned())
@add_test_categories(["pyapi"])
@expectedFlakeyNetBSD
diff --git a/lldb/test/API/commands/frame/language/TestGuessLanguage.py b/lldb/test/API/commands/frame/language/TestGuessLanguage.py
index e2912d3bf17312..dbf581ed7a12d9 100644
--- a/lldb/test/API/commands/frame/language/TestGuessLanguage.py
+++ b/lldb/test/API/commands/frame/language/TestGuessLanguage.py
@@ -59,7 +59,7 @@ def do_test(self):
)
# The hit count for the breakpoint should be 1.
- self.assertEquals(breakpoint.GetHitCount(), 1)
+ self.assertEqual(breakpoint.GetHitCount(), 1)
thread = threads[0]
diff --git a/lldb/test/API/commands/frame/var/TestFrameVar.py b/lldb/test/API/commands/frame/var/TestFrameVar.py
index c43121abfe4325..92e47eb45f5ca5 100644
--- a/lldb/test/API/commands/frame/var/TestFrameVar.py
+++ b/lldb/test/API/commands/frame/var/TestFrameVar.py
@@ -52,7 +52,7 @@ def do_test(self):
)
# The hit count for the breakpoint should be 1.
- self.assertEquals(breakpoint.GetHitCount(), 1)
+ self.assertEqual(breakpoint.GetHitCount(), 1)
frame = threads[0].GetFrameAtIndex(0)
command_result = lldb.SBCommandReturnObject()
diff --git a/lldb/test/API/commands/log/basic/TestLogging.py b/lldb/test/API/commands/log/basic/TestLogging.py
index 52d86a1f81aece..daa32dc85753dc 100644
--- a/lldb/test/API/commands/log/basic/TestLogging.py
+++ b/lldb/test/API/commands/log/basic/TestLogging.py
@@ -62,7 +62,7 @@ def test_log_truncate(self):
contents = f.read()
# check that it got removed
- self.assertEquals(contents.find("bacon"), -1)
+ self.assertEqual(contents.find("bacon"), -1)
# Check that lldb can append to a log file
def test_log_append(self):
@@ -79,7 +79,7 @@ def test_log_append(self):
contents = f.read()
# check that it is still there
- self.assertEquals(contents.find("bacon"), 0)
+ self.assertEqual(contents.find("bacon"), 0)
# Enable all log options and check that nothing crashes.
@skipIfWindows
diff --git a/lldb/test/API/commands/memory/read/TestMemoryRead.py b/lldb/test/API/commands/memory/read/TestMemoryRead.py
index cd7ad1bedc7067..67b28ee79067b2 100644
--- a/lldb/test/API/commands/memory/read/TestMemoryRead.py
+++ b/lldb/test/API/commands/memory/read/TestMemoryRead.py
@@ -57,7 +57,7 @@ def test_memory_read(self):
address = int(items[0], 0)
argc = int(items[1], 0)
self.assertGreater(address, 0)
- self.assertEquals(argc, 1)
+ self.assertEqual(argc, 1)
# (lldb) memory read --format uint32_t[] --size 4 --count 4 `&argc`
# 0x7fff5fbff9a0: {0x00000001}
@@ -130,7 +130,7 @@ def test_memory_read(self):
# Check that we got back 4 0x0000 etc bytes
for o in objects_read:
self.assertEqual(len(o), expected_object_length)
- self.assertEquals(len(objects_read), 4)
+ self.assertEqual(len(objects_read), 4)
def test_memory_read_file(self):
self.build_run_stop()
diff --git a/lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py b/lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
index 02f0592f40de6d..cde218c783f12d 100644
--- a/lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
+++ b/lldb/test/API/commands/watchpoints/step_over_watchpoint/TestStepOverWatchpoint.py
@@ -53,11 +53,11 @@ def test_step_over_read_watchpoint(self):
lldb.eStopReasonWatchpoint,
STOPPED_DUE_TO_WATCHPOINT,
)
- self.assertEquals(thread.GetStopDescription(20), "watchpoint 1")
+ self.assertEqual(thread.GetStopDescription(20), "watchpoint 1")
process.Continue()
self.assertState(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED)
- self.assertEquals(thread.GetStopDescription(20), "step over")
+ self.assertEqual(thread.GetStopDescription(20), "step over")
self.step_inst_for_watchpoint(1)
@@ -95,11 +95,11 @@ def test_step_over_write_watchpoint(self):
lldb.eStopReasonWatchpoint,
STOPPED_DUE_TO_WATCHPOINT,
)
- self.assertEquals(thread.GetStopDescription(20), "watchpoint 1")
+ self.assertEqual(thread.GetStopDescription(20), "watchpoint 1")
process.Continue()
self.assertState(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED)
- self.assertEquals(thread.GetStopDescription(20), "step over")
+ self.assertEqual(thread.GetStopDescription(20), "step over")
self.step_inst_for_watchpoint(1)
@@ -113,7 +113,7 @@ def step_inst_for_watchpoint(self, wp_id):
self.assertFalse(watchpoint_hit, "Watchpoint already hit.")
expected_stop_desc = "watchpoint %d" % wp_id
actual_stop_desc = self.thread().GetStopDescription(20)
- self.assertEquals(
+ self.assertEqual(
actual_stop_desc, expected_stop_desc, "Watchpoint ID didn't match."
)
watchpoint_hit = True
diff --git a/lldb/test/API/driver/job_control/TestJobControl.py b/lldb/test/API/driver/job_control/TestJobControl.py
index 632f5ef2b8654f..1a1739f4cb391d 100644
--- a/lldb/test/API/driver/job_control/TestJobControl.py
+++ b/lldb/test/API/driver/job_control/TestJobControl.py
@@ -22,7 +22,7 @@ def post_spawn():
status = int(self.child.match[1])
self.assertTrue(os.WIFSTOPPED(status))
- self.assertEquals(os.WSTOPSIG(status), signal.SIGTSTP)
+ self.assertEqual(os.WSTOPSIG(status), signal.SIGTSTP)
os.kill(self.lldb_pid, signal.SIGCONT)
diff --git a/lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py b/lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py
index 04272ad56e4781..3ceccc6e6d6416 100644
--- a/lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py
+++ b/lldb/test/API/functionalities/breakpoint/address_breakpoints/TestAddressBreakpoints.py
@@ -64,7 +64,7 @@ def address_breakpoints(self):
)
# The hit count for the breakpoint should be 1.
- self.assertEquals(breakpoint.GetHitCount(), 1)
+ self.assertEqual(breakpoint.GetHitCount(), 1)
process.Kill()
@@ -82,4 +82,4 @@ def address_breakpoints(self):
# The hit count for the breakpoint should be 1, since we reset counts
# for each run.
- self.assertEquals(breakpoint.GetHitCount(), 1)
+ self.assertEqual(breakpoint.GetHitCount(), 1)
diff --git a/lldb/test/API/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py b/lldb/test/API/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py
index 1b44a6183c9826..0ab11a427c1009 100644
--- a/lldb/test/API/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py
+++ b/lldb/test/API/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py
@@ -40,7 +40,7 @@ def address_breakpoints(self):
bkpt = target.BreakpointCreateByAddress(illegal_address)
# Verify that breakpoint is not resolved.
for bp_loc in bkpt:
- self.assertEquals(bp_loc.IsResolved(), False)
+ self.assertEqual(bp_loc.IsResolved(), False)
else:
self.fail(
"Could not find an illegal address at which to set a bad breakpo...
[truncated]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
Thanks! Nice cleanup. |
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. (cherry picked from commit 80fcecb)
Fixes new test that were added or modified after #82073. Also fixes a formatting issue.
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.