[Lldb-commits] [lldb] 9c24688 - [lldb][test] Modernize asserts (#82503)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Feb 21 11:02:35 PST 2024
Author: Jordan Rupprecht
Date: 2024-02-21T13:02:30-06:00
New Revision: 9c2468821ec51defd09c246fea4a47886fff8c01
URL: https://github.com/llvm/llvm-project/commit/9c2468821ec51defd09c246fea4a47886fff8c01
DIFF: https://github.com/llvm/llvm-project/commit/9c2468821ec51defd09c246fea4a47886fff8c01.diff
LOG: [lldb][test] Modernize asserts (#82503)
This uses [teyit](https://pypi.org/project/teyit/) to modernize asserts,
as recommended by the [unittest release
notes](https://docs.python.org/3.12/whatsnew/3.12.html#id3).
For example, `assertTrue(a == b)` is replaced with `assertEqual(a, b)`.
This produces better error messages, e.g. `error: unexpectedly found 1
and 2 to be different` instead of `error: False`.
Added:
Modified:
lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py
lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py
lldb/test/API/commands/expression/completion-crash-invalid-iterator/TestInvalidIteratorCompletionCrash.py
lldb/test/API/commands/expression/fixits/TestFixIts.py
lldb/test/API/commands/expression/test/TestExprs.py
lldb/test/API/commands/expression/unwind_expression/TestUnwindExpression.py
lldb/test/API/commands/register/register/aarch64_sme_z_registers/save_restore/TestSMEZRegistersSaveRestore.py
lldb/test/API/commands/register/register/aarch64_sme_z_registers/za_dynamic_resize/TestZAThreadedDynamic.py
lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
lldb/test/API/commands/session/save/TestSessionSave.py
lldb/test/API/commands/statistics/basic/TestStats.py
lldb/test/API/commands/trace/TestTraceExport.py
lldb/test/API/commands/trace/TestTraceSave.py
lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py
lldb/test/API/functionalities/archives/TestBSDArchives.py
lldb/test/API/functionalities/asan/TestMemoryHistory.py
lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py
lldb/test/API/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
lldb/test/API/functionalities/breakpoint/objc/TestObjCBreakpoints.py
lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
lldb/test/API/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py
lldb/test/API/functionalities/gdb_remote_client/TestMSP430MSPDebug.py
lldb/test/API/functionalities/multidebugger_commands/TestMultipleDebuggersCommands.py
lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py
lldb/test/API/functionalities/return-value/TestReturnValue.py
lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
lldb/test/API/functionalities/signal/TestSendSignal.py
lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py
lldb/test/API/functionalities/signal/handle-segv/TestHandleSegv.py
lldb/test/API/functionalities/signal/raise/TestRaise.py
lldb/test/API/functionalities/step-avoids-no-debug/TestStepNoDebug.py
lldb/test/API/functionalities/step-avoids-regexp/TestStepAvoidsRegexp.py
lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
lldb/test/API/functionalities/thread/break_after_join/TestBreakAfterJoin.py
lldb/test/API/functionalities/thread/create_during_step/TestCreateDuringStep.py
lldb/test/API/functionalities/thread/exit_during_break/TestExitDuringBreak.py
lldb/test/API/functionalities/thread/multi_break/TestMultipleBreakpoints.py
lldb/test/API/functionalities/thread/num_threads/TestNumThreads.py
lldb/test/API/functionalities/thread_plan/TestThreadPlanCommands.py
lldb/test/API/functionalities/tsan/basic/TestTsanBasic.py
lldb/test/API/functionalities/tsan/multiple/TestTsanMultiple.py
lldb/test/API/functionalities/unwind/aarch64_unwind_pac/TestAArch64UnwindPAC.py
lldb/test/API/lang/c/register_variables/TestRegisterVariables.py
lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py
lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py
lldb/test/API/lang/cpp/namespace/TestNamespace.py
lldb/test/API/lang/cpp/stl/TestSTL.py
lldb/test/API/lang/objc/foundation/TestFoundationDisassembly.py
lldb/test/API/lang/objc/objc-class-method/TestObjCClassMethod.py
lldb/test/API/lang/objc/objc-struct-argument/TestObjCStructArgument.py
lldb/test/API/lang/objc/objc-struct-return/TestObjCStructReturn.py
lldb/test/API/lang/objc/objc-super/TestObjCSuper.py
lldb/test/API/lang/objc/rdar-12408181/TestRdar12408181.py
lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
lldb/test/API/linux/aarch64/tagged_memory_access/TestAArch64LinuxTaggedMemoryAccess.py
lldb/test/API/linux/aarch64/unwind_signal/TestUnwindSignal.py
lldb/test/API/lua_api/TestLuaAPI.py
lldb/test/API/macosx/function-starts/TestFunctionStarts.py
lldb/test/API/macosx/objc_exception_recognizer/TestObjCRecognizer.py
lldb/test/API/macosx/profile_vrs_detach/TestDetachVrsProfile.py
lldb/test/API/macosx/queues/TestQueues.py
lldb/test/API/macosx/universal/TestUniversal.py
lldb/test/API/python_api/event/TestEvents.py
lldb/test/API/python_api/file_handle/TestFileHandle.py
lldb/test/API/python_api/findvalue_duplist/TestSBFrameFindValue.py
lldb/test/API/python_api/format/TestFormat.py
lldb/test/API/python_api/formatters/TestFormattersSBAPI.py
lldb/test/API/python_api/frame/get-variables/TestGetVariables.py
lldb/test/API/python_api/module_section/TestModuleAndSection.py
lldb/test/API/python_api/process/TestProcessAPI.py
lldb/test/API/python_api/process/io/TestProcessIO.py
lldb/test/API/python_api/sbdata/TestSBData.py
lldb/test/API/python_api/sbmodule/TestSBModule.py
lldb/test/API/python_api/target/TestTargetAPI.py
lldb/test/API/python_api/type/TestTypeList.py
lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py
lldb/test/API/python_api/value/change_values/libcxx/atomic/TestChangeValue.py
lldb/test/API/python_api/value/change_values/libcxx/map/TestChangeMapValue.py
lldb/test/API/python_api/watchpoint/TestWatchpointIter.py
lldb/test/API/source-manager/TestSourceManager.py
lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py
lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py
lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py
lldb/test/API/tools/lldb-dap/terminated-event/TestDAP_terminatedEvent.py
lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py
lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py
lldb/test/API/tools/lldb-server/TestGdbRemoteAuxvSupport.py
lldb/test/API/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py
lldb/test/API/tools/lldb-server/TestGdbRemoteRegisterState.py
lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py
lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py
Removed:
################################################################################
diff --git a/lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py b/lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py
index 214d890db3fe34..ca08591aedb392 100644
--- a/lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py
+++ b/lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py
@@ -84,7 +84,7 @@ def call_function(self):
handler_bkpt = target.BreakpointCreateBySourceRegex(
"Got sigchld %d.", self.main_source_spec
)
- self.assertTrue(handler_bkpt.GetNumLocations() > 0)
+ self.assertGreater(handler_bkpt.GetNumLocations(), 0)
options.SetIgnoreBreakpoints(True)
options.SetUnwindOnError(True)
diff --git a/lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py b/lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py
index 8d524ad9e9b6fb..2868ec5ffdbdf8 100644
--- a/lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py
+++ b/lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py
@@ -55,7 +55,7 @@ def call_function(self):
handler_bkpt = target.BreakpointCreateBySourceRegex(
"I felt like it", self.main_source_spec
)
- self.assertTrue(handler_bkpt.GetNumLocations() > 0)
+ self.assertGreater(handler_bkpt.GetNumLocations(), 0)
options.SetIgnoreBreakpoints(True)
options.SetUnwindOnError(True)
@@ -69,7 +69,7 @@ def call_function(self):
exception_bkpt = target.BreakpointCreateForException(
lldb.eLanguageTypeObjC, False, True
)
- self.assertTrue(exception_bkpt.GetNumLocations() > 0)
+ self.assertGreater(exception_bkpt.GetNumLocations(), 0)
options.SetIgnoreBreakpoints(True)
options.SetUnwindOnError(True)
diff --git a/lldb/test/API/commands/expression/completion-crash-invalid-iterator/TestInvalidIteratorCompletionCrash.py b/lldb/test/API/commands/expression/completion-crash-invalid-iterator/TestInvalidIteratorCompletionCrash.py
index b031b63b4e2673..4c7620a7e18db6 100644
--- a/lldb/test/API/commands/expression/completion-crash-invalid-iterator/TestInvalidIteratorCompletionCrash.py
+++ b/lldb/test/API/commands/expression/completion-crash-invalid-iterator/TestInvalidIteratorCompletionCrash.py
@@ -11,7 +11,7 @@ def test(self):
callee_break = target.BreakpointCreateByName(
"SomeClass::SomeClass(ParamClass)", None
)
- self.assertTrue(callee_break.GetNumLocations() > 0)
+ self.assertGreater(callee_break.GetNumLocations(), 0)
self.runCmd("run", RUN_SUCCEEDED)
to_complete = "e ParamClass"
diff --git a/lldb/test/API/commands/expression/fixits/TestFixIts.py b/lldb/test/API/commands/expression/fixits/TestFixIts.py
index 3289bc0c5c7e03..bc53b72fe611b9 100644
--- a/lldb/test/API/commands/expression/fixits/TestFixIts.py
+++ b/lldb/test/API/commands/expression/fixits/TestFixIts.py
@@ -79,11 +79,11 @@ def test_with_target(self):
self.assertTrue(value.IsValid())
self.assertTrue(value.GetError().Fail())
error_string = value.GetError().GetCString()
- self.assertTrue(
- error_string.find("fixed expression suggested:") != -1, "Fix was suggested"
+ self.assertNotEqual(
+ error_string.find("fixed expression suggested:"), -1, "Fix was suggested"
)
- self.assertTrue(
- error_string.find("my_pointer->second.a") != -1, "Fix was right"
+ self.assertNotEqual(
+ error_string.find("my_pointer->second.a"), -1, "Fix was right"
)
def test_with_target_error_applies_fixit(self):
diff --git a/lldb/test/API/commands/expression/test/TestExprs.py b/lldb/test/API/commands/expression/test/TestExprs.py
index 0e3215522ea6e8..41faf07f8cb44a 100644
--- a/lldb/test/API/commands/expression/test/TestExprs.py
+++ b/lldb/test/API/commands/expression/test/TestExprs.py
@@ -163,7 +163,7 @@ def test_evaluate_expression_python(self):
self.DebugSBValue(val)
callee_break = target.BreakpointCreateByName("a_function_to_call", None)
- self.assertTrue(callee_break.GetNumLocations() > 0)
+ self.assertGreater(callee_break.GetNumLocations(), 0)
# Make sure ignoring breakpoints works from the command line:
self.expect(
diff --git a/lldb/test/API/commands/expression/unwind_expression/TestUnwindExpression.py b/lldb/test/API/commands/expression/unwind_expression/TestUnwindExpression.py
index bb173c0584a46e..82f062876a773f 100644
--- a/lldb/test/API/commands/expression/unwind_expression/TestUnwindExpression.py
+++ b/lldb/test/API/commands/expression/unwind_expression/TestUnwindExpression.py
@@ -70,8 +70,9 @@ def do_unwind_test(self, thread, bkpt, timeout):
self.assertTrue(val.GetError().Fail(), "We did not complete the execution.")
error_str = val.GetError().GetCString()
- self.assertTrue(
- "Execution was interrupted, reason: breakpoint" in error_str,
+ self.assertIn(
+ "Execution was interrupted, reason: breakpoint",
+ error_str,
"And the reason was right.",
)
diff --git a/lldb/test/API/commands/register/register/aarch64_sme_z_registers/save_restore/TestSMEZRegistersSaveRestore.py b/lldb/test/API/commands/register/register/aarch64_sme_z_registers/save_restore/TestSMEZRegistersSaveRestore.py
index 9433aae0c53c45..40e9c821bc64d5 100644
--- a/lldb/test/API/commands/register/register/aarch64_sme_z_registers/save_restore/TestSMEZRegistersSaveRestore.py
+++ b/lldb/test/API/commands/register/register/aarch64_sme_z_registers/save_restore/TestSMEZRegistersSaveRestore.py
@@ -55,7 +55,7 @@ def get_supported_svg(self):
# Write back the current vg to confirm read/write works at all.
current_svg = self.match("register read vg", ["(0x[0-9]+)"])
- self.assertTrue(current_svg is not None)
+ self.assertIsNotNone(current_svg)
self.expect("register write vg {}".format(current_svg.group()))
# Aka 128, 256 and 512 bit.
diff --git a/lldb/test/API/commands/register/register/aarch64_sme_z_registers/za_dynamic_resize/TestZAThreadedDynamic.py b/lldb/test/API/commands/register/register/aarch64_sme_z_registers/za_dynamic_resize/TestZAThreadedDynamic.py
index 8b1d5908d96ca7..1929c46264d7df 100644
--- a/lldb/test/API/commands/register/register/aarch64_sme_z_registers/za_dynamic_resize/TestZAThreadedDynamic.py
+++ b/lldb/test/API/commands/register/register/aarch64_sme_z_registers/za_dynamic_resize/TestZAThreadedDynamic.py
@@ -28,7 +28,7 @@ def get_supported_vg(self):
)
current_vg = self.match("register read vg", ["(0x[0-9]+)"])
- self.assertTrue(current_vg is not None)
+ self.assertIsNotNone(current_vg)
self.expect("register write vg {}".format(current_vg.group()))
# Aka 128, 256 and 512 bit.
diff --git a/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py b/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
index 5d5914bef35465..759dde96a9f150 100644
--- a/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
+++ b/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
@@ -40,7 +40,7 @@ def get_supported_vg(self):
# Write back the current vg to confirm read/write works at all.
current_vg = self.match("register read vg", ["(0x[0-9]+)"])
- self.assertTrue(current_vg is not None)
+ self.assertIsNotNone(current_vg)
self.expect("register write vg {}".format(current_vg.group()))
# Aka 128, 256 and 512 bit.
diff --git a/lldb/test/API/commands/session/save/TestSessionSave.py b/lldb/test/API/commands/session/save/TestSessionSave.py
index 6a40ec1eaf037a..172a7645230463 100644
--- a/lldb/test/API/commands/session/save/TestSessionSave.py
+++ b/lldb/test/API/commands/session/save/TestSessionSave.py
@@ -47,7 +47,7 @@ def test_session_save(self):
raw += self.raw_transcript_builder(cmd, res)
self.assertTrue(interpreter.HasCommands())
- self.assertTrue(len(raw) != 0)
+ self.assertNotEqual(len(raw), 0)
# Check for error
cmd = "session save /root/file"
diff --git a/lldb/test/API/commands/statistics/basic/TestStats.py b/lldb/test/API/commands/statistics/basic/TestStats.py
index 0172ac536e9791..6f083222227fbf 100644
--- a/lldb/test/API/commands/statistics/basic/TestStats.py
+++ b/lldb/test/API/commands/statistics/basic/TestStats.py
@@ -600,7 +600,7 @@ def test_had_frame_variable_errors(self):
# Get stats and verify we had errors.
stats = self.get_stats()
exe_stats = self.find_module_in_metrics(exe, stats)
- self.assertTrue(exe_stats is not None)
+ self.assertIsNotNone(exe_stats)
# Make sure we have "debugInfoHadVariableErrors" variable that is set to
# false before failing to get local variables due to missing .o file.
@@ -620,7 +620,7 @@ def test_had_frame_variable_errors(self):
# Get stats and verify we had errors.
stats = self.get_stats()
exe_stats = self.find_module_in_metrics(exe, stats)
- self.assertTrue(exe_stats is not None)
+ self.assertIsNotNone(exe_stats)
# Make sure we have "hadFrameVariableErrors" variable that is set to
# true after failing to get local variables due to missing .o file.
diff --git a/lldb/test/API/commands/trace/TestTraceExport.py b/lldb/test/API/commands/trace/TestTraceExport.py
index 7d237f7f1846c6..a6ca736d3c5a40 100644
--- a/lldb/test/API/commands/trace/TestTraceExport.py
+++ b/lldb/test/API/commands/trace/TestTraceExport.py
@@ -229,7 +229,7 @@ def _testHtrBasicSuperBlockPassSequenceCheck(self):
index_of_first_layer_1_block = None
for i, event in enumerate(data):
layer_id = event.get("pid")
- self.assertTrue(layer_id is not None)
+ self.assertIsNotNone(layer_id)
if layer_id == 1 and index_of_first_layer_1_block is None:
index_of_first_layer_1_block = i
num_units_by_layer[layer_id] += 1
diff --git a/lldb/test/API/commands/trace/TestTraceSave.py b/lldb/test/API/commands/trace/TestTraceSave.py
index cc2d373220b829..ef1ab2f7aa41c8 100644
--- a/lldb/test/API/commands/trace/TestTraceSave.py
+++ b/lldb/test/API/commands/trace/TestTraceSave.py
@@ -103,7 +103,7 @@ def checkSessionBundle(session_file_path):
with open(session_file_path) as session_file:
session = json.load(session_file)
# We expect tsc conversion info
- self.assertTrue("tscPerfZeroConversion" in session)
+ self.assertIn("tscPerfZeroConversion", session)
# We expect at least one cpu
self.assertGreater(len(session["cpus"]), 0)
@@ -152,18 +152,18 @@ def checkSessionBundle(session_file_path):
copied_process = find(
lambda proc: proc["pid"] == process["pid"], copy["processes"]
)
- self.assertTrue(copied_process is not None)
+ self.assertIsNotNone(copied_process)
for thread in process["threads"]:
copied_thread = find(
lambda thr: thr["tid"] == thread["tid"],
copied_process["threads"],
)
- self.assertTrue(copied_thread is not None)
+ self.assertIsNotNone(copied_thread)
for cpu in original["cpus"]:
copied_cpu = find(lambda cor: cor["id"] == cpu["id"], copy["cpus"])
- self.assertTrue(copied_cpu is not None)
+ self.assertIsNotNone(copied_cpu)
def testSaveTrace(self):
self.expect(
@@ -225,7 +225,7 @@ def testSaveKernelTrace(self):
original_file = json.load(original_file)
with open(copied_trace_file) as copy_file:
copy_file = json.load(copy_file)
- self.assertTrue("kernel" in copy_file)
+ self.assertIn("kernel", copy_file)
self.assertEqual(
os.path.basename(original_file["kernel"]["file"]),
diff --git a/lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py b/lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py
index 4bb58e7d027f78..c41e85fd670baa 100644
--- a/lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py
+++ b/lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py
@@ -236,7 +236,7 @@ def testStartPerCpuSession(self):
].strip()
output = json.loads(response)
- self.assertTrue(output is not None)
+ self.assertIsNotNone(output)
self.assertIn("cpus", output)
self.assertIn("tscPerfZeroConversion", output)
found_non_empty_context_switch = False
@@ -249,8 +249,8 @@ def testStartPerCpuSession(self):
ipt_trace_size = binary_data["size"]
elif binary_data["kind"] == "perfContextSwitchTrace":
context_switch_size = binary_data["size"]
- self.assertTrue(context_switch_size is not None)
- self.assertTrue(ipt_trace_size is not None)
+ self.assertIsNotNone(context_switch_size)
+ self.assertIsNotNone(ipt_trace_size)
if context_switch_size > 0:
found_non_empty_context_switch = True
diff --git a/lldb/test/API/functionalities/archives/TestBSDArchives.py b/lldb/test/API/functionalities/archives/TestBSDArchives.py
index 570fd2ed8c0e60..1bef8e896e0be7 100644
--- a/lldb/test/API/functionalities/archives/TestBSDArchives.py
+++ b/lldb/test/API/functionalities/archives/TestBSDArchives.py
@@ -85,13 +85,15 @@ def check_frame_variable_errors(self, thread, error_strings):
api_error = var_list.GetError().GetCString()
for s in error_strings:
- self.assertTrue(
- s in command_error,
+ self.assertIn(
+ s,
+ command_error,
'Make sure "%s" exists in the command error "%s"' % (s, command_error),
)
for s in error_strings:
- self.assertTrue(
- s in api_error,
+ self.assertIn(
+ s,
+ api_error,
'Make sure "%s" exists in the API error "%s"' % (s, api_error),
)
diff --git a/lldb/test/API/functionalities/asan/TestMemoryHistory.py b/lldb/test/API/functionalities/asan/TestMemoryHistory.py
index b746651afe28da..00162ae8822c74 100644
--- a/lldb/test/API/functionalities/asan/TestMemoryHistory.py
+++ b/lldb/test/API/functionalities/asan/TestMemoryHistory.py
@@ -87,7 +87,7 @@ def asan_tests(self):
self.assertEqual(threads.GetSize(), 2)
history_thread = threads.GetThreadAtIndex(0)
- self.assertTrue(history_thread.num_frames >= 2)
+ self.assertGreaterEqual(history_thread.num_frames, 2)
self.assertEqual(
history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(),
"main.c",
@@ -97,7 +97,7 @@ def asan_tests(self):
)
history_thread = threads.GetThreadAtIndex(1)
- self.assertTrue(history_thread.num_frames >= 2)
+ self.assertGreaterEqual(history_thread.num_frames, 2)
self.assertEqual(
history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(),
"main.c",
@@ -109,7 +109,7 @@ def asan_tests(self):
# let's free the container (SBThreadCollection) and see if the
# SBThreads still live
threads = None
- self.assertTrue(history_thread.num_frames >= 2)
+ self.assertGreaterEqual(history_thread.num_frames, 2)
self.assertEqual(
history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(),
"main.c",
diff --git a/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py b/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
index 923d8f8dc9ae56..620f648d51fd29 100644
--- a/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
+++ b/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
@@ -86,8 +86,9 @@ def test_breakpoints_with_relative_path_line_tables(self):
]
for path in valid_paths:
bkpt = target.BreakpointCreateByLocation(path, 2)
- self.assertTrue(
- bkpt.GetNumLocations() > 0,
+ self.assertGreater(
+ bkpt.GetNumLocations(),
+ 0,
'Couldn\'t resolve breakpoint using full path "%s" in executate "%s" with '
"debug info that has relative path with matching suffix"
% (path, self.getBuildArtifact("a.out")),
@@ -142,8 +143,9 @@ def test_breakpoints_with_bad_aranges(self):
target = self.dbg.CreateTarget(obj_path)
src_path = "/tmp/ab/main.cpp"
bkpt = target.BreakpointCreateByLocation(src_path, 2)
- self.assertTrue(
- bkpt.GetNumLocations() > 0,
+ self.assertGreater(
+ bkpt.GetNumLocations(),
+ 0,
'Couldn\'t resolve breakpoint using "%s" in executate "%s" with '
"debug info that has a bad .debug_aranges section"
% (src_path, self.getBuildArtifact("a.out")),
@@ -613,8 +615,9 @@ def test_breakpoints_auto_source_map_relative(self):
# is a suffix of request breakpoint file path
path = "/x/y/a/b/c/main.cpp"
bp = target.BreakpointCreateByLocation(path, 2)
- self.assertTrue(
- bp.GetNumLocations() > 0,
+ self.assertGreater(
+ bp.GetNumLocations(),
+ 0,
'Couldn\'t resolve breakpoint using full path "%s" in executate "%s" with '
"debug info that has relative path with matching suffix"
% (path, self.getBuildArtifact("a.out")),
@@ -632,8 +635,9 @@ def test_breakpoints_auto_source_map_relative(self):
# equals the file path in debug info.
path = "a/b/c/main.cpp"
bp = target.BreakpointCreateByLocation(path, 2)
- self.assertTrue(
- bp.GetNumLocations() > 0,
+ self.assertGreater(
+ bp.GetNumLocations(),
+ 0,
'Couldn\'t resolve breakpoint using full path "%s" in executate "%s" with '
"debug info that has relative path with matching suffix"
% (path, self.getBuildArtifact("a.out")),
diff --git a/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py b/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py
index 36f37870629be0..7889f08ba8dbbc 100644
--- a/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py
+++ b/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py
@@ -76,7 +76,9 @@ def do_set_python_command_from_python(self):
)
self.assertTrue(no_files_bkpt, VALID_BREAKPOINT)
num_locations = no_files_bkpt.GetNumLocations()
- self.assertTrue(num_locations >= 2, "Got at least two breakpoint locations")
+ self.assertGreaterEqual(
+ num_locations, 2, "Got at least two breakpoint locations"
+ )
got_one_in_A = False
got_one_in_B = False
for idx in range(0, num_locations):
diff --git a/lldb/test/API/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py b/lldb/test/API/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
index 4fcf19cf7df089..50ba0317fd094e 100644
--- a/lldb/test/API/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
+++ b/lldb/test/API/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py
@@ -143,8 +143,8 @@ def breakpoint_conditions_python(self):
"The thread index should be invalid",
)
# The thread name should be invalid, too.
- self.assertTrue(
- breakpoint.GetThreadName() is None, "The thread name should be invalid"
+ self.assertIsNone(
+ breakpoint.GetThreadName(), "The thread name should be invalid"
)
# Let's set the thread index for this breakpoint and verify that it is,
diff --git a/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
index 5325f0f00affb8..b3568653002a21 100644
--- a/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
+++ b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py
@@ -45,8 +45,8 @@ def test_step_range(self):
error = lldb.SBError()
thread.StepInto("", 4, error)
self.assertTrue(error.Fail())
- self.assertTrue(
- "Could not create hardware breakpoint for thread plan" in error.GetCString()
+ self.assertIn(
+ "Could not create hardware breakpoint for thread plan", error.GetCString()
)
@skipTestIfFn(HardwareBreakpointTestBase.supports_hw_breakpoints)
@@ -67,8 +67,8 @@ def test_step_out(self):
error = lldb.SBError()
thread.StepOut(error)
self.assertTrue(error.Fail())
- self.assertTrue(
- "Could not create hardware breakpoint for thread plan" in error.GetCString()
+ self.assertIn(
+ "Could not create hardware breakpoint for thread plan", error.GetCString()
)
@skipTestIfFn(HardwareBreakpointTestBase.supports_hw_breakpoints)
@@ -107,6 +107,6 @@ def test_step_until(self):
# Ensure we fail when stepping through the API.
error = thread.StepOverUntil(lldb.SBFrame(), lldb.SBFileSpec(), 5)
self.assertTrue(error.Fail())
- self.assertTrue(
- "Could not create hardware breakpoint for thread plan" in error.GetCString()
+ self.assertIn(
+ "Could not create hardware breakpoint for thread plan", error.GetCString()
)
diff --git a/lldb/test/API/functionalities/breakpoint/objc/TestObjCBreakpoints.py b/lldb/test/API/functionalities/breakpoint/objc/TestObjCBreakpoints.py
index b81e144e44af4a..29cf31563a9a9c 100644
--- a/lldb/test/API/functionalities/breakpoint/objc/TestObjCBreakpoints.py
+++ b/lldb/test/API/functionalities/breakpoint/objc/TestObjCBreakpoints.py
@@ -42,8 +42,9 @@ def check_category_breakpoints(self):
)
for bp_loc in selector_bp:
function_name = bp_loc.GetAddress().GetSymbol().GetName()
- self.assertTrue(
- " myCategoryFunction]" in function_name,
+ self.assertIn(
+ " myCategoryFunction]",
+ function_name,
'Make sure all function names have " myCategoryFunction]" in their names',
)
@@ -108,8 +109,9 @@ def check_objc_breakpoints(self, have_dsym):
) # There are 93 on the latest MacOSX
for bp_loc in selector_bp:
function_name = bp_loc.GetAddress().GetSymbol().GetName()
- self.assertTrue(
- " count]" in function_name,
+ self.assertIn(
+ " count]",
+ function_name,
'Make sure all function names have " count]" in their names',
)
@@ -132,8 +134,9 @@ def check_objc_breakpoints(self, have_dsym):
)
for bp_loc in selector_bp:
function_name = bp_loc.GetAddress().GetSymbol().GetName()
- self.assertTrue(
- " isEqual:]" in function_name,
+ self.assertIn(
+ " isEqual:]",
+ function_name,
'Make sure all function names have " isEqual:]" in their names',
)
diff --git a/lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py b/lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
index 9f477f951cd863..0a1003a1b238c4 100644
--- a/lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
+++ b/lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
@@ -123,8 +123,8 @@ def do_test(self):
# Make sure these all got locations:
for i in range(0, len(right)):
- self.assertTrue(
- right[i].GetNumLocations() >= 1, "Breakpoint %d has no locations." % (i)
+ self.assertGreaterEqual(
+ right[i].GetNumLocations(), 1, "Breakpoint %d has no locations." % (i)
)
# Now some ones that won't take:
@@ -229,7 +229,7 @@ def do_test_depths(self):
bkpt = target.BreakpointCreateFromScript(
"resolver.Resolver", extra_args, module_list, file_list
)
- self.assertTrue(bkpt.GetNumLocations() > 0, "Resolver got no locations.")
+ self.assertGreater(bkpt.GetNumLocations(), 0, "Resolver got no locations.")
self.expect(
"script print(resolver.Resolver.got_files)",
substrs=["2"],
@@ -240,8 +240,8 @@ def do_test_depths(self):
bkpt = target.BreakpointCreateFromScript(
"resolver.ResolverModuleDepth", extra_args, module_list, file_list
)
- self.assertTrue(
- bkpt.GetNumLocations() > 0, "ResolverModuleDepth got no locations."
+ self.assertGreater(
+ bkpt.GetNumLocations(), 0, "ResolverModuleDepth got no locations."
)
self.expect(
"script print(resolver.Resolver.got_files)",
@@ -253,7 +253,9 @@ def do_test_depths(self):
bkpt = target.BreakpointCreateFromScript(
"resolver.ResolverCUDepth", extra_args, module_list, file_list
)
- self.assertTrue(bkpt.GetNumLocations() > 0, "ResolverCUDepth got no locations.")
+ self.assertGreater(
+ bkpt.GetNumLocations(), 0, "ResolverCUDepth got no locations."
+ )
self.expect(
"script print(resolver.Resolver.got_files)",
substrs=["1"],
@@ -264,8 +266,8 @@ def do_test_depths(self):
bkpt = target.BreakpointCreateFromScript(
"resolver.ResolverBadDepth", extra_args, module_list, file_list
)
- self.assertTrue(
- bkpt.GetNumLocations() > 0, "ResolverBadDepth got no locations."
+ self.assertGreater(
+ bkpt.GetNumLocations(), 0, "ResolverBadDepth got no locations."
)
self.expect(
"script print(resolver.Resolver.got_files)",
@@ -277,8 +279,8 @@ def do_test_depths(self):
bkpt = target.BreakpointCreateFromScript(
"resolver.ResolverFuncDepth", extra_args, module_list, file_list
)
- self.assertTrue(
- bkpt.GetNumLocations() > 0, "ResolverFuncDepth got no locations."
+ self.assertGreater(
+ bkpt.GetNumLocations(), 0, "ResolverFuncDepth got no locations."
)
self.expect(
"script print(resolver.Resolver.got_files)",
diff --git a/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py b/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
index 985bafabdc5bcc..411ce9c67da02f 100644
--- a/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
+++ b/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
@@ -60,7 +60,7 @@ def test_resolver_serialization(self):
exe_module.IsValid(), "Failed to find the executable module in target"
)
sym_ctx_list = exe_module.FindFunctions("main")
- self.assertTrue(sym_ctx_list.GetSize() == 1, "Unable to find function 'main'")
+ self.assertEqual(sym_ctx_list.GetSize(), 1, "Unable to find function 'main'")
sym_ctx = sym_ctx_list.GetContextAtIndex(0)
self.assertTrue(
sym_ctx.IsValid(), "SBSymbolContext representing function 'main' is invalid"
diff --git a/lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py b/lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
index 15539b022bc850..3a7440a31677ac 100644
--- a/lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
+++ b/lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
@@ -87,7 +87,7 @@ def test_step_instruction(self):
self.thread.GetFrameAtIndex(0).GetLineEntry().GetLine(), self.line4
)
# breakpoint_2 and _3 should not affect step count
- self.assertTrue(step_count >= steps_expected)
+ self.assertGreaterEqual(step_count, steps_expected)
break
# Run the process until termination
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py b/lldb/test/API/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
index cae1e3b498b065..512840b9f06551 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
@@ -315,11 +315,13 @@ def cleanup():
if self.TraceOn():
print(str_cast)
- self.assertTrue(str_cast.find("A") != -1, "could not find A in output")
- self.assertTrue(str_cast.find("B") != -1, "could not find B in output")
- self.assertTrue(str_cast.find("C") != -1, "could not find C in output")
- self.assertTrue(str_cast.find("D") != -1, "could not find D in output")
- self.assertTrue(str_cast.find("4 = '\\0'") != -1, "could not find item 4 == 0")
+ self.assertNotEqual(str_cast.find("A"), -1, "could not find A in output")
+ self.assertNotEqual(str_cast.find("B"), -1, "could not find B in output")
+ self.assertNotEqual(str_cast.find("C"), -1, "could not find C in output")
+ self.assertNotEqual(str_cast.find("D"), -1, "could not find D in output")
+ self.assertNotEqual(
+ str_cast.find("4 = '\\0'"), -1, "could not find item 4 == 0"
+ )
self.dbg.GetSelectedTarget().GetProcess().GetSelectedThread().StepOver()
@@ -331,8 +333,10 @@ def cleanup():
# we detect that all the values of the child objects have changed - but the counter-generated item
# is still fixed at 0 because it is cached - this would fail if update(self): in ftsp returned False
# or if synthetic children were not being preserved
- self.assertTrue(str_cast.find("Q") != -1, "could not find Q in output")
- self.assertTrue(str_cast.find("X") != -1, "could not find X in output")
- self.assertTrue(str_cast.find("T") != -1, "could not find T in output")
- self.assertTrue(str_cast.find("F") != -1, "could not find F in output")
- self.assertTrue(str_cast.find("4 = '\\0'") != -1, "could not find item 4 == 0")
+ self.assertNotEqual(str_cast.find("Q"), -1, "could not find Q in output")
+ self.assertNotEqual(str_cast.find("X"), -1, "could not find X in output")
+ self.assertNotEqual(str_cast.find("T"), -1, "could not find T in output")
+ self.assertNotEqual(str_cast.find("F"), -1, "could not find F in output")
+ self.assertNotEqual(
+ str_cast.find("4 = '\\0'"), -1, "could not find item 4 == 0"
+ )
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
index e2d2e67f1e885e..98438742a11ca6 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
@@ -83,17 +83,17 @@ def cleanup():
uncappedSummaryStream = lldb.SBStream()
TheVeryLongOne.GetSummary(uncappedSummaryStream, summaryOptions)
uncappedSummary = uncappedSummaryStream.GetData()
- self.assertTrue(
- uncappedSummary.find("someText") > 0,
+ self.assertGreater(
+ uncappedSummary.find("someText"),
+ 0,
"uncappedSummary does not include the full string",
)
summaryOptions.SetCapping(lldb.eTypeSummaryCapped)
cappedSummaryStream = lldb.SBStream()
TheVeryLongOne.GetSummary(cappedSummaryStream, summaryOptions)
cappedSummary = cappedSummaryStream.GetData()
- self.assertTrue(
- cappedSummary.find("someText") <= 0,
- "cappedSummary includes the full string",
+ self.assertLessEqual(
+ cappedSummary.find("someText"), 0, "cappedSummary includes the full string"
)
self.expect_expr(
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py
index 660eb09db20da2..eb7b394660b4be 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py
@@ -105,17 +105,17 @@ def cleanup():
uncappedSummaryStream = lldb.SBStream()
TheVeryLongOne.GetSummary(uncappedSummaryStream, summaryOptions)
uncappedSummary = uncappedSummaryStream.GetData()
- self.assertTrue(
- uncappedSummary.find("someText") > 0,
+ self.assertGreater(
+ uncappedSummary.find("someText"),
+ 0,
"uncappedSummary does not include the full string",
)
summaryOptions.SetCapping(lldb.eTypeSummaryCapped)
cappedSummaryStream = lldb.SBStream()
TheVeryLongOne.GetSummary(cappedSummaryStream, summaryOptions)
cappedSummary = cappedSummaryStream.GetData()
- self.assertTrue(
- cappedSummary.find("someText") <= 0,
- "cappedSummary includes the full string",
+ self.assertLessEqual(
+ cappedSummary.find("someText"), 0, "cappedSummary includes the full string"
)
self.expect_expr(
diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestMSP430MSPDebug.py b/lldb/test/API/functionalities/gdb_remote_client/TestMSP430MSPDebug.py
index 1359db491c24e4..1dc6f89d1ea00b 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestMSP430MSPDebug.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestMSP430MSPDebug.py
@@ -74,8 +74,8 @@ def test(self):
# Test if the breakpoint address is resolved correctly
self.assertEqual(bp.GetNumLocations(), 1, "Only one location")
bp_loc = bp.GetLocationAtIndex(0)
- self.assertTrue(
- bp_loc.GetAddress().GetLoadAddress(target) == 0x510, "Address of main"
+ self.assertEqual(
+ bp_loc.GetAddress().GetLoadAddress(target), 0x510, "Address of main"
)
# Test if the process stops at the breakpoint
@@ -93,8 +93,9 @@ def test(self):
# Test if thread can step a single instruction
thread.StepInstruction(False)
- self.assertTrue(
- thread.GetFrameAtIndex(0).GetPCAddress().GetLoadAddress(target) == 0x516,
+ self.assertEqual(
+ thread.GetFrameAtIndex(0).GetPCAddress().GetLoadAddress(target),
+ 0x516,
"Address of the next instruction",
)
@@ -122,6 +123,6 @@ def test(self):
self.assertEqual(reg.GetValueAsUnsigned(), reg_val_dict[reg.GetName()])
# Check if backtracing works:
- self.assertTrue(len(thread.frames) >= 3)
+ self.assertGreaterEqual(len(thread.frames), 3)
crt0_addr = thread.GetFrameAtIndex(2).GetPCAddress().GetLoadAddress(target)
self.assertEqual(crt0_addr, 0x50A)
diff --git a/lldb/test/API/functionalities/multidebugger_commands/TestMultipleDebuggersCommands.py b/lldb/test/API/functionalities/multidebugger_commands/TestMultipleDebuggersCommands.py
index 4ed08833632db2..98d7e8e9212fab 100644
--- a/lldb/test/API/functionalities/multidebugger_commands/TestMultipleDebuggersCommands.py
+++ b/lldb/test/API/functionalities/multidebugger_commands/TestMultipleDebuggersCommands.py
@@ -20,8 +20,9 @@ def test_multipledebuggers_commands(self):
retobj = lldb.SBCommandReturnObject()
interpreter_1.HandleCommand("apropos env", retobj)
- self.assertTrue(
- magic_text in str(retobj),
+ self.assertIn(
+ magic_text,
+ str(retobj),
"[interpreter_1]: the output does not contain the correct words",
)
@@ -37,8 +38,9 @@ def test_multipledebuggers_commands(self):
retobj = lldb.SBCommandReturnObject()
interpreter_2.HandleCommand("apropos env", retobj)
- self.assertTrue(
- magic_text in str(retobj),
+ self.assertIn(
+ magic_text,
+ str(retobj),
"[interpreter_2]: the output does not contain the correct words",
)
diff --git a/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py b/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py
index a0e2afbf477d0f..9fe5e89142987d 100644
--- a/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py
+++ b/lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py
@@ -22,7 +22,7 @@ def verify_core_file(
self.assertTrue(process, PROCESS_IS_VALID)
self.assertTrue(process.GetProcessInfo().IsValid())
self.assertEqual(process.GetProcessInfo().GetProcessID(), expected_pid)
- self.assertTrue(target.GetTriple().find("linux") != -1)
+ self.assertNotEqual(target.GetTriple().find("linux"), -1)
self.assertTrue(target.GetNumModules(), len(expected_modules))
self.assertEqual(process.GetNumThreads(), len(expected_threads))
@@ -40,7 +40,7 @@ def verify_core_file(
thread = process.GetThreadAtIndex(thread_idx)
self.assertTrue(thread.IsValid())
thread_id = thread.GetThreadID()
- self.assertTrue(thread_id in expected_threads)
+ self.assertIn(thread_id, expected_threads)
self.dbg.DeleteTarget(target)
@skipUnlessArch("x86_64")
diff --git a/lldb/test/API/functionalities/return-value/TestReturnValue.py b/lldb/test/API/functionalities/return-value/TestReturnValue.py
index 3c212a3be660bf..89e6e67583d7cb 100644
--- a/lldb/test/API/functionalities/return-value/TestReturnValue.py
+++ b/lldb/test/API/functionalities/return-value/TestReturnValue.py
@@ -261,8 +261,9 @@ def return_and_test_struct_value(self, func_name):
# Set the breakpoint, run to it, finish out.
bkpt = self.target.BreakpointCreateByName(func_name)
- self.assertTrue(
- bkpt.GetNumResolvedLocations() > 0,
+ self.assertGreater(
+ bkpt.GetNumResolvedLocations(),
+ 0,
"Got wrong number of locations for {0}".format(func_name),
)
diff --git a/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py b/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
index 837ceea22ad164..5aaf68575623ce 100644
--- a/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
+++ b/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
@@ -201,9 +201,7 @@ def cleanup():
py_impl = process_0.GetScriptedImplementation()
self.assertTrue(py_impl)
- self.assertTrue(
- isinstance(py_impl, dummy_scripted_process.DummyScriptedProcess)
- )
+ self.assertIsInstance(py_impl, dummy_scripted_process.DummyScriptedProcess)
self.assertFalse(hasattr(py_impl, "my_super_secret_member"))
py_impl.my_super_secret_member = 42
self.assertTrue(hasattr(py_impl, "my_super_secret_member"))
diff --git a/lldb/test/API/functionalities/signal/TestSendSignal.py b/lldb/test/API/functionalities/signal/TestSendSignal.py
index 94d435a5fb17f6..50435572c4d83a 100644
--- a/lldb/test/API/functionalities/signal/TestSendSignal.py
+++ b/lldb/test/API/functionalities/signal/TestSendSignal.py
@@ -75,8 +75,8 @@ def test_with_run_command(self):
self.assertEqual(len(threads), 1, "One thread stopped for a signal.")
thread = threads[0]
- self.assertTrue(
- thread.GetStopReasonDataCount() >= 1, "There was data in the event."
+ self.assertGreaterEqual(
+ thread.GetStopReasonDataCount(), 1, "There was data in the event."
)
self.assertEqual(
thread.GetStopReasonDataAtIndex(0),
diff --git a/lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py b/lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py
index a20a6a90407297..488ae9833c9eea 100644
--- a/lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py
+++ b/lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py
@@ -33,8 +33,8 @@ def test_inferior_handle_sigabrt(self):
self.assertTrue(
thread and thread.IsValid(), "Thread should be stopped due to a signal"
)
- self.assertTrue(
- thread.GetStopReasonDataCount() >= 1, "There should be data in the event."
+ self.assertGreaterEqual(
+ thread.GetStopReasonDataCount(), 1, "There should be data in the event."
)
self.assertEqual(
thread.GetStopReasonDataAtIndex(0),
diff --git a/lldb/test/API/functionalities/signal/handle-segv/TestHandleSegv.py b/lldb/test/API/functionalities/signal/handle-segv/TestHandleSegv.py
index 65718f88520487..de0d9e392d8107 100644
--- a/lldb/test/API/functionalities/signal/handle-segv/TestHandleSegv.py
+++ b/lldb/test/API/functionalities/signal/handle-segv/TestHandleSegv.py
@@ -29,8 +29,8 @@ def test_inferior_handle_sigsegv(self):
self.assertTrue(
thread and thread.IsValid(), "Thread should be stopped due to a signal"
)
- self.assertTrue(
- thread.GetStopReasonDataCount() >= 1, "There was data in the event."
+ self.assertGreaterEqual(
+ thread.GetStopReasonDataCount(), 1, "There was data in the event."
)
self.assertEqual(
thread.GetStopReasonDataAtIndex(0), signo, "The stop signal was SIGSEGV"
diff --git a/lldb/test/API/functionalities/signal/raise/TestRaise.py b/lldb/test/API/functionalities/signal/raise/TestRaise.py
index 874b06a2de3ed7..9a6f2e6b70f390 100644
--- a/lldb/test/API/functionalities/signal/raise/TestRaise.py
+++ b/lldb/test/API/functionalities/signal/raise/TestRaise.py
@@ -88,8 +88,8 @@ def signal_test(self, signal, test_passing):
self.assertState(process.GetState(), lldb.eStateStopped)
thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonSignal)
self.assertTrue(thread.IsValid(), "Thread should be stopped due to a signal")
- self.assertTrue(
- thread.GetStopReasonDataCount() >= 1, "There was data in the event."
+ self.assertGreaterEqual(
+ thread.GetStopReasonDataCount(), 1, "There was data in the event."
)
self.assertEqual(
thread.GetStopReasonDataAtIndex(0), signo, "The stop signal was %s" % signal
@@ -137,8 +137,8 @@ def signal_test(self, signal, test_passing):
self.assertState(process.GetState(), lldb.eStateStopped)
thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonSignal)
self.assertTrue(thread.IsValid(), "Thread should be stopped due to a signal")
- self.assertTrue(
- thread.GetStopReasonDataCount() >= 1, "There was data in the event."
+ self.assertGreaterEqual(
+ thread.GetStopReasonDataCount(), 1, "There was data in the event."
)
self.assertEqual(
thread.GetStopReasonDataAtIndex(0),
diff --git a/lldb/test/API/functionalities/step-avoids-no-debug/TestStepNoDebug.py b/lldb/test/API/functionalities/step-avoids-no-debug/TestStepNoDebug.py
index 984a9c1b51c571..a5ec87274a5ba7 100644
--- a/lldb/test/API/functionalities/step-avoids-no-debug/TestStepNoDebug.py
+++ b/lldb/test/API/functionalities/step-avoids-no-debug/TestStepNoDebug.py
@@ -83,8 +83,9 @@ def hit_correct_line(self, pattern):
def hit_correct_function(self, pattern):
name = self.thread.frames[0].GetFunctionName()
- self.assertTrue(
- pattern in name,
+ self.assertIn(
+ pattern,
+ name,
"Got to '%s' not the expected function '%s'." % (name, pattern),
)
diff --git a/lldb/test/API/functionalities/step-avoids-regexp/TestStepAvoidsRegexp.py b/lldb/test/API/functionalities/step-avoids-regexp/TestStepAvoidsRegexp.py
index 26ab880c6ca67a..ca56436eeae1e5 100644
--- a/lldb/test/API/functionalities/step-avoids-regexp/TestStepAvoidsRegexp.py
+++ b/lldb/test/API/functionalities/step-avoids-regexp/TestStepAvoidsRegexp.py
@@ -11,8 +11,9 @@
class StepAvoidsRegexTestCase(TestBase):
def hit_correct_function(self, pattern):
name = self.thread.frames[0].GetFunctionName()
- self.assertTrue(
- pattern in name,
+ self.assertIn(
+ pattern,
+ name,
"Got to '%s' not the expected function '%s'." % (name, pattern),
)
diff --git a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
index c454c28b225017..abf761fb3420b4 100644
--- a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
+++ b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
@@ -85,8 +85,9 @@ def test_launch_notifications(self):
# when reading dyld from the expanded shared cache.
exe_basename = lldb.SBFileSpec(exe).basename
if module.file.basename not in ["dyld", exe_basename]:
- self.assertTrue(
- module not in already_loaded_modules,
+ self.assertNotIn(
+ module,
+ already_loaded_modules,
"{} is already loaded".format(module),
)
already_loaded_modules.append(module)
diff --git a/lldb/test/API/functionalities/thread/break_after_join/TestBreakAfterJoin.py b/lldb/test/API/functionalities/thread/break_after_join/TestBreakAfterJoin.py
index 45533abc2b2b75..eb5692e782e083 100644
--- a/lldb/test/API/functionalities/thread/break_after_join/TestBreakAfterJoin.py
+++ b/lldb/test/API/functionalities/thread/break_after_join/TestBreakAfterJoin.py
@@ -73,8 +73,9 @@ def test(self):
num_threads = process.GetNumThreads()
# Make sure we see at least six threads
- self.assertTrue(
- num_threads >= 6,
+ self.assertGreaterEqual(
+ num_threads,
+ 6,
"Number of expected threads and actual threads do not match.",
)
diff --git a/lldb/test/API/functionalities/thread/create_during_step/TestCreateDuringStep.py b/lldb/test/API/functionalities/thread/create_during_step/TestCreateDuringStep.py
index 597a83edad3dc6..44851ed4f54821 100644
--- a/lldb/test/API/functionalities/thread/create_during_step/TestCreateDuringStep.py
+++ b/lldb/test/API/functionalities/thread/create_during_step/TestCreateDuringStep.py
@@ -137,12 +137,14 @@ def create_during_step_base(self, step_cmd, step_stop_reason):
current_line = frame.GetLineEntry().GetLine()
# Make sure we're still where we thought we were
- self.assertTrue(
- current_line >= self.breakpoint,
+ self.assertGreaterEqual(
+ current_line,
+ self.breakpoint,
"Stepped to unexpected line, " + str(current_line),
)
- self.assertTrue(
- current_line <= self.continuepoint,
+ self.assertLessEqual(
+ current_line,
+ self.continuepoint,
"Stepped to unexpected line, " + str(current_line),
)
diff --git a/lldb/test/API/functionalities/thread/exit_during_break/TestExitDuringBreak.py b/lldb/test/API/functionalities/thread/exit_during_break/TestExitDuringBreak.py
index f377716f3bf8f8..41559b34b074e5 100644
--- a/lldb/test/API/functionalities/thread/exit_during_break/TestExitDuringBreak.py
+++ b/lldb/test/API/functionalities/thread/exit_during_break/TestExitDuringBreak.py
@@ -49,8 +49,9 @@ def test(self):
num_threads = process.GetNumThreads()
# Make sure we see at least five threads
- self.assertTrue(
- num_threads >= 5,
+ self.assertGreaterEqual(
+ num_threads,
+ 5,
"Number of expected threads and actual threads do not match.",
)
diff --git a/lldb/test/API/functionalities/thread/multi_break/TestMultipleBreakpoints.py b/lldb/test/API/functionalities/thread/multi_break/TestMultipleBreakpoints.py
index 8ae5d0eee75a52..bfd712037f0df4 100644
--- a/lldb/test/API/functionalities/thread/multi_break/TestMultipleBreakpoints.py
+++ b/lldb/test/API/functionalities/thread/multi_break/TestMultipleBreakpoints.py
@@ -60,8 +60,9 @@ def test(self):
num_threads = process.GetNumThreads()
# Make sure we see all three threads
- self.assertTrue(
- num_threads >= 3,
+ self.assertGreaterEqual(
+ num_threads,
+ 3,
"Number of expected threads and actual threads do not match.",
)
diff --git a/lldb/test/API/functionalities/thread/num_threads/TestNumThreads.py b/lldb/test/API/functionalities/thread/num_threads/TestNumThreads.py
index 7e4059cc0dfc7c..ee9b14f15b6e95 100644
--- a/lldb/test/API/functionalities/thread/num_threads/TestNumThreads.py
+++ b/lldb/test/API/functionalities/thread/num_threads/TestNumThreads.py
@@ -63,8 +63,9 @@ def test_number_of_threads(self):
# Using std::thread may involve extra threads, so we assert that there are
# at least 4 rather than exactly 4.
- self.assertTrue(
- num_threads >= 13,
+ self.assertGreaterEqual(
+ num_threads,
+ 13,
"Number of expected threads and actual threads do not match.",
)
@@ -98,8 +99,9 @@ def test_unique_stacks(self):
# Using std::thread may involve extra threads, so we assert that there are
# at least 10 thread3's rather than exactly 10.
- self.assertTrue(
- num_threads >= 10,
+ self.assertGreaterEqual(
+ num_threads,
+ 10,
"Number of expected threads and actual threads do not match.",
)
diff --git a/lldb/test/API/functionalities/thread_plan/TestThreadPlanCommands.py b/lldb/test/API/functionalities/thread_plan/TestThreadPlanCommands.py
index 7d03f4e884cbe2..86ddabd30d2401 100644
--- a/lldb/test/API/functionalities/thread_plan/TestThreadPlanCommands.py
+++ b/lldb/test/API/functionalities/thread_plan/TestThreadPlanCommands.py
@@ -121,8 +121,8 @@ def thread_plan_test(self):
call_me_bkpt = target.BreakpointCreateBySourceRegex(
"Set another here", self.main_source_file
)
- self.assertTrue(
- call_me_bkpt.GetNumLocations() > 0, "Set the breakpoint successfully"
+ self.assertGreater(
+ call_me_bkpt.GetNumLocations(), 0, "Set the breakpoint successfully"
)
thread.StepUsingScriptedThreadPlan("wrap_step_over.WrapStepOver")
threads = lldbutil.get_threads_stopped_at_breakpoint(process, call_me_bkpt)
@@ -170,14 +170,14 @@ def thread_plan_test(self):
second_step_bkpt = target.BreakpointCreateBySourceRegex(
"Run here to step over again", self.main_source_file
)
- self.assertTrue(
- second_step_bkpt.GetNumLocations() > 0, "Set the breakpoint successfully"
+ self.assertGreater(
+ second_step_bkpt.GetNumLocations(), 0, "Set the breakpoint successfully"
)
final_bkpt = target.BreakpointCreateBySourceRegex(
"Make sure we get here on last continue", self.main_source_file
)
- self.assertTrue(
- final_bkpt.GetNumLocations() > 0, "Set the breakpoint successfully"
+ self.assertGreater(
+ final_bkpt.GetNumLocations(), 0, "Set the breakpoint successfully"
)
threads = lldbutil.continue_to_breakpoint(process, second_step_bkpt)
diff --git a/lldb/test/API/functionalities/tsan/basic/TestTsanBasic.py b/lldb/test/API/functionalities/tsan/basic/TestTsanBasic.py
index de20d6ae8e2f3e..ca8b74e35dff62 100644
--- a/lldb/test/API/functionalities/tsan/basic/TestTsanBasic.py
+++ b/lldb/test/API/functionalities/tsan/basic/TestTsanBasic.py
@@ -102,7 +102,7 @@ def tsan_tests(self):
backtraces = thread.GetStopReasonExtendedBacktraces(
lldb.eInstrumentationRuntimeTypeThreadSanitizer
)
- self.assertTrue(backtraces.GetSize() >= 2)
+ self.assertGreaterEqual(backtraces.GetSize(), 2)
# First backtrace is a memory operation
thread = backtraces.GetThreadAtIndex(0)
diff --git a/lldb/test/API/functionalities/tsan/multiple/TestTsanMultiple.py b/lldb/test/API/functionalities/tsan/multiple/TestTsanMultiple.py
index 6d844fc9b07346..435e18084a79bf 100644
--- a/lldb/test/API/functionalities/tsan/multiple/TestTsanMultiple.py
+++ b/lldb/test/API/functionalities/tsan/multiple/TestTsanMultiple.py
@@ -84,7 +84,7 @@ def tsan_tests(self):
lldb.eInstrumentationRuntimeTypeThreadSanitizer
)
)
- self.assertTrue(backtraces.GetSize() >= 1)
+ self.assertGreaterEqual(backtraces.GetSize(), 1)
self.runCmd("continue")
diff --git a/lldb/test/API/functionalities/unwind/aarch64_unwind_pac/TestAArch64UnwindPAC.py b/lldb/test/API/functionalities/unwind/aarch64_unwind_pac/TestAArch64UnwindPAC.py
index e98df17ad43db5..17e120d93f065e 100644
--- a/lldb/test/API/functionalities/unwind/aarch64_unwind_pac/TestAArch64UnwindPAC.py
+++ b/lldb/test/API/functionalities/unwind/aarch64_unwind_pac/TestAArch64UnwindPAC.py
@@ -49,7 +49,9 @@ def test(self):
"_start",
]
- self.assertTrue(thread.GetNumFrames() >= (len(backtrace) + len(libc_backtrace)))
+ self.assertGreaterEqual(
+ thread.GetNumFrames(), len(backtrace) + len(libc_backtrace)
+ )
# Strictly check frames that are in the test program's source.
for frame_idx, frame in enumerate(thread.frames[: len(backtrace)]):
diff --git a/lldb/test/API/lang/c/register_variables/TestRegisterVariables.py b/lldb/test/API/lang/c/register_variables/TestRegisterVariables.py
index 0f91aa5d044eef..0e51d4f7ff4681 100644
--- a/lldb/test/API/lang/c/register_variables/TestRegisterVariables.py
+++ b/lldb/test/API/lang/c/register_variables/TestRegisterVariables.py
@@ -148,8 +148,9 @@ def test_and_run_command(self):
)
# Validate that we verified at least one register variable
- self.assertTrue(
- register_variables_count > 0,
+ self.assertGreater(
+ register_variables_count,
+ 0,
"expected to verify at least one variable in a register",
)
self.trace(
diff --git a/lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py b/lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py
index 15b65ad35bcdb5..8d0de40cdd7b68 100644
--- a/lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py
+++ b/lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py
@@ -82,7 +82,7 @@ def test_and_python_api(self):
# Check that the stop ID increases:
new_stop_id = process.GetStopID()
- self.assertTrue(new_stop_id > old_stop_id, "Stop ID increases monotonically.")
+ self.assertGreater(new_stop_id, old_stop_id, "Stop ID increases monotonically.")
thread = threads[0]
@@ -141,8 +141,9 @@ def test_and_python_api(self):
"Expression calling doesn't change stop ID",
)
- self.assertTrue(
- stop_id_after_including_expressions > stop_id_before_including_expressions,
+ self.assertGreater(
+ stop_id_after_including_expressions,
+ stop_id_before_including_expressions,
"Stop ID including expressions increments over expression call.",
)
diff --git a/lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py b/lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py
index 44a584f7dd63e4..60a2590e1559d3 100644
--- a/lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py
+++ b/lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py
@@ -144,7 +144,7 @@ def test_get_dynamic_vals(self):
anotherA_dynamic_typename = anotherA_dynamic.GetTypeName()
self.assertNotEqual(anotherA_dynamic_typename.find("B"), -1)
- self.assertTrue(anotherA_dynamic_addr < anotherA_static_addr)
+ self.assertLess(anotherA_dynamic_addr, anotherA_static_addr)
anotherA_m_b_value_dynamic = anotherA_dynamic.GetChildMemberWithName(
"m_b_value", True
@@ -204,7 +204,7 @@ def examine_value_object_of_this_ptr(
# And that the static address is greater than the dynamic one
- self.assertTrue(this_static_loc > this_dynamic_loc)
+ self.assertGreater(this_static_loc, this_dynamic_loc)
# Now read m_b_value which is only in the dynamic value:
@@ -252,4 +252,4 @@ def examine_value_object_of_this_ptr(
contained_b_addr = int(contained_b.GetValue(), 16)
contained_b_static_addr = int(contained_b_static.GetValue(), 16)
- self.assertTrue(contained_b_addr < contained_b_static_addr)
+ self.assertLess(contained_b_addr, contained_b_static_addr)
diff --git a/lldb/test/API/lang/cpp/namespace/TestNamespace.py b/lldb/test/API/lang/cpp/namespace/TestNamespace.py
index 3006699b6623a2..d747e2be77c8e4 100644
--- a/lldb/test/API/lang/cpp/namespace/TestNamespace.py
+++ b/lldb/test/API/lang/cpp/namespace/TestNamespace.py
@@ -32,8 +32,9 @@ def test_breakpoints_func_auto(self):
)
for bp_loc in bp:
name = bp_loc.GetAddress().GetFunction().GetName()
- self.assertTrue(
- name in names,
+ self.assertIn(
+ name,
+ names,
"make sure breakpoint locations are correct for 'func' with eFunctionNameTypeAuto",
)
@@ -61,8 +62,9 @@ def test_breakpoints_func_full(self):
)
for bp_loc in bp:
name = bp_loc.GetAddress().GetFunction().GetName()
- self.assertTrue(
- name in names,
+ self.assertIn(
+ name,
+ names,
"make sure breakpoint locations are correct for 'func' with eFunctionNameTypeFull",
)
@@ -88,8 +90,9 @@ def test_breakpoints_a_func_full(self):
)
for bp_loc in bp:
name = bp_loc.GetAddress().GetFunction().GetName()
- self.assertTrue(
- name in names,
+ self.assertIn(
+ name,
+ names,
"make sure breakpoint locations are correct for 'A::func' with eFunctionNameTypeFull",
)
diff --git a/lldb/test/API/lang/cpp/stl/TestSTL.py b/lldb/test/API/lang/cpp/stl/TestSTL.py
index d7d75b25aa522c..ee4f04661610f9 100644
--- a/lldb/test/API/lang/cpp/stl/TestSTL.py
+++ b/lldb/test/API/lang/cpp/stl/TestSTL.py
@@ -50,7 +50,7 @@ def test_SBType_template_aspects(self):
self.DebugSBType(map_type)
self.assertTrue(map_type, VALID_TYPE)
num_template_args = map_type.GetNumberOfTemplateArguments()
- self.assertTrue(num_template_args > 0)
+ self.assertGreater(num_template_args, 0)
# We expect the template arguments to contain at least 'string' and
# 'int'.
diff --git a/lldb/test/API/lang/objc/foundation/TestFoundationDisassembly.py b/lldb/test/API/lang/objc/foundation/TestFoundationDisassembly.py
index 301f9cb90f5c9d..245313d6837746 100644
--- a/lldb/test/API/lang/objc/foundation/TestFoundationDisassembly.py
+++ b/lldb/test/API/lang/objc/foundation/TestFoundationDisassembly.py
@@ -34,9 +34,7 @@ def test_foundation_disasm(self):
foundation_framework = module.file.fullpath
break
- self.assertTrue(
- foundation_framework is not None, "Foundation.framework path located"
- )
+ self.assertIsNotNone(foundation_framework, "Foundation.framework path located")
self.runCmd("image dump symtab '%s'" % foundation_framework)
raw_output = self.res.GetOutput()
# Now, grab every 'Code' symbol and feed it into the command:
diff --git a/lldb/test/API/lang/objc/objc-class-method/TestObjCClassMethod.py b/lldb/test/API/lang/objc/objc-class-method/TestObjCClassMethod.py
index 29f5aeec1418de..473d6241485ec2 100644
--- a/lldb/test/API/lang/objc/objc-class-method/TestObjCClassMethod.py
+++ b/lldb/test/API/lang/objc/objc-class-method/TestObjCClassMethod.py
@@ -35,7 +35,7 @@ def test_with_python_api(self):
thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, bpt)
# Make sure we stopped at the first breakpoint.
- self.assertTrue(len(thread_list) != 0, "No thread stopped at our breakpoint.")
+ self.assertNotEqual(len(thread_list), 0, "No thread stopped at our breakpoint.")
self.assertEqual(
len(thread_list), 1, "More than one thread stopped at our breakpoint."
)
diff --git a/lldb/test/API/lang/objc/objc-struct-argument/TestObjCStructArgument.py b/lldb/test/API/lang/objc/objc-struct-argument/TestObjCStructArgument.py
index 9ffcc715ad8305..480d99523e8a2a 100644
--- a/lldb/test/API/lang/objc/objc-struct-argument/TestObjCStructArgument.py
+++ b/lldb/test/API/lang/objc/objc-struct-argument/TestObjCStructArgument.py
@@ -38,7 +38,7 @@ def test_with_python_api(self):
thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, bpt)
# Make sure we stopped at the first breakpoint.
- self.assertTrue(len(thread_list) != 0, "No thread stopped at our breakpoint.")
+ self.assertNotEqual(len(thread_list), 0, "No thread stopped at our breakpoint.")
self.assertEqual(
len(thread_list), 1, "More than one thread stopped at our breakpoint."
)
diff --git a/lldb/test/API/lang/objc/objc-struct-return/TestObjCStructReturn.py b/lldb/test/API/lang/objc/objc-struct-return/TestObjCStructReturn.py
index d704ed2114f452..520b89c7e2199e 100644
--- a/lldb/test/API/lang/objc/objc-struct-return/TestObjCStructReturn.py
+++ b/lldb/test/API/lang/objc/objc-struct-return/TestObjCStructReturn.py
@@ -36,7 +36,7 @@ def test_with_python_api(self):
thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, bpt)
# Make sure we stopped at the first breakpoint.
- self.assertTrue(len(thread_list) != 0, "No thread stopped at our breakpoint.")
+ self.assertNotEqual(len(thread_list), 0, "No thread stopped at our breakpoint.")
self.assertEqual(
len(thread_list), 1, "More than one thread stopped at our breakpoint."
)
diff --git a/lldb/test/API/lang/objc/objc-super/TestObjCSuper.py b/lldb/test/API/lang/objc/objc-super/TestObjCSuper.py
index 8e446224c0ade3..eb640dc20af946 100644
--- a/lldb/test/API/lang/objc/objc-super/TestObjCSuper.py
+++ b/lldb/test/API/lang/objc/objc-super/TestObjCSuper.py
@@ -36,7 +36,7 @@ def test_with_python_api(self):
thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, bpt)
# Make sure we stopped at the first breakpoint.
- self.assertTrue(len(thread_list) != 0, "No thread stopped at our breakpoint.")
+ self.assertNotEqual(len(thread_list), 0, "No thread stopped at our breakpoint.")
self.assertEqual(
len(thread_list), 1, "More than one thread stopped at our breakpoint."
)
diff --git a/lldb/test/API/lang/objc/rdar-12408181/TestRdar12408181.py b/lldb/test/API/lang/objc/rdar-12408181/TestRdar12408181.py
index 50cb20a3de4705..80942a8abd6ed2 100644
--- a/lldb/test/API/lang/objc/rdar-12408181/TestRdar12408181.py
+++ b/lldb/test/API/lang/objc/rdar-12408181/TestRdar12408181.py
@@ -49,11 +49,12 @@ def test_nswindow_count(self):
):
window = self.frame().FindVariable("window")
window_dynamic = window.GetDynamicValue(lldb.eDynamicCanRunTarget)
- self.assertTrue(
- window.GetNumChildren() > 1, "NSWindow (static) only has 1 child!"
+ self.assertGreater(
+ window.GetNumChildren(), 1, "NSWindow (static) only has 1 child!"
)
- self.assertTrue(
- window_dynamic.GetNumChildren() > 1,
+ self.assertGreater(
+ window_dynamic.GetNumChildren(),
+ 1,
"NSWindow (dynamic) only has 1 child!",
)
self.assertTrue(
diff --git a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
index 698b16df783609..1eb7205f1bb465 100644
--- a/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
+++ b/lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py
@@ -35,7 +35,7 @@ def test_with_python_api(self):
thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, bpt)
# Make sure we stopped at the first breakpoint.
- self.assertTrue(len(thread_list) != 0, "No thread stopped at our breakpoint.")
+ self.assertNotEqual(len(thread_list), 0, "No thread stopped at our breakpoint.")
self.assertEqual(
len(thread_list), 1, "More than one thread stopped at our breakpoint."
)
diff --git a/lldb/test/API/linux/aarch64/tagged_memory_access/TestAArch64LinuxTaggedMemoryAccess.py b/lldb/test/API/linux/aarch64/tagged_memory_access/TestAArch64LinuxTaggedMemoryAccess.py
index c023e77e57d5ac..1b52cd4b9c488b 100644
--- a/lldb/test/API/linux/aarch64/tagged_memory_access/TestAArch64LinuxTaggedMemoryAccess.py
+++ b/lldb/test/API/linux/aarch64/tagged_memory_access/TestAArch64LinuxTaggedMemoryAccess.py
@@ -84,6 +84,4 @@ def test_tagged_memory_find(self):
# First check we actually got something.
self.assertRegex(out, "data found at location: 0x[0-9A-Fa-f]+")
# Then that the location found does not display the tag bits.
- self.assertNotRegexpMatches(
- out, "data found at location: 0x(34|56)[0-9A-Fa-f]+"
- )
+ self.assertNotRegex(out, "data found at location: 0x(34|56)[0-9A-Fa-f]+")
diff --git a/lldb/test/API/linux/aarch64/unwind_signal/TestUnwindSignal.py b/lldb/test/API/linux/aarch64/unwind_signal/TestUnwindSignal.py
index 0ac43f2b088010..46f05b8285a515 100644
--- a/lldb/test/API/linux/aarch64/unwind_signal/TestUnwindSignal.py
+++ b/lldb/test/API/linux/aarch64/unwind_signal/TestUnwindSignal.py
@@ -32,8 +32,8 @@ def test_unwind_signal(self):
self.assertTrue(
thread and thread.IsValid(), "Thread should be stopped due to a signal"
)
- self.assertTrue(
- thread.GetStopReasonDataCount() >= 1, "There should be data in the event."
+ self.assertGreaterEqual(
+ thread.GetStopReasonDataCount(), 1, "There should be data in the event."
)
self.assertEqual(
thread.GetStopReasonDataAtIndex(0),
diff --git a/lldb/test/API/lua_api/TestLuaAPI.py b/lldb/test/API/lua_api/TestLuaAPI.py
index 4063e80264a276..4c9a5d9672c4c6 100644
--- a/lldb/test/API/lua_api/TestLuaAPI.py
+++ b/lldb/test/API/lua_api/TestLuaAPI.py
@@ -186,4 +186,4 @@ def test_lua_api(self):
print(out)
print(err, file=sys.stderr)
- self.assertTrue(exitCode == 0, "Lua test '%s' failure." % lua_test)
+ self.assertEqual(exitCode, 0, "Lua test '%s' failure." % lua_test)
diff --git a/lldb/test/API/macosx/function-starts/TestFunctionStarts.py b/lldb/test/API/macosx/function-starts/TestFunctionStarts.py
index 7b08c9a56ba838..80b042827fb116 100644
--- a/lldb/test/API/macosx/function-starts/TestFunctionStarts.py
+++ b/lldb/test/API/macosx/function-starts/TestFunctionStarts.py
@@ -64,8 +64,8 @@ def do_function_starts(self, in_memory):
self.assertSuccess(error, "Didn't attach successfully to %d" % (popen.pid))
bkpt = target.BreakpointCreateByName("dont_strip_me", exe)
- self.assertTrue(
- bkpt.GetNumLocations() > 0, "Didn't set the dont_strip_me bkpt."
+ self.assertGreater(
+ bkpt.GetNumLocations(), 0, "Didn't set the dont_strip_me bkpt."
)
threads = lldbutil.continue_to_breakpoint(process, bkpt)
@@ -74,6 +74,6 @@ def do_function_starts(self, in_memory):
# Our caller frame should have been stripped. Make sure we made a synthetic symbol
# for it:
thread = threads[0]
- self.assertTrue(thread.num_frames > 1, "Couldn't backtrace.")
+ self.assertGreater(thread.num_frames, 1, "Couldn't backtrace.")
name = thread.frame[1].GetFunctionName()
self.assertTrue(name.startswith("___lldb_unnamed_symbol"))
diff --git a/lldb/test/API/macosx/objc_exception_recognizer/TestObjCRecognizer.py b/lldb/test/API/macosx/objc_exception_recognizer/TestObjCRecognizer.py
index c46c39346be4c4..f49e7ca0837bba 100644
--- a/lldb/test/API/macosx/objc_exception_recognizer/TestObjCRecognizer.py
+++ b/lldb/test/API/macosx/objc_exception_recognizer/TestObjCRecognizer.py
@@ -41,8 +41,8 @@ def objc_recognizer_test(self, sub_class):
exception_bkpt = target.BreakpointCreateForException(
lldb.eLanguageTypeObjC, False, True
)
- self.assertTrue(
- exception_bkpt.GetNumLocations() > 0, "Got some exception locations"
+ self.assertGreater(
+ exception_bkpt.GetNumLocations(), 0, "Got some exception locations"
)
threads = lldbutil.continue_to_breakpoint(process, exception_bkpt)
diff --git a/lldb/test/API/macosx/profile_vrs_detach/TestDetachVrsProfile.py b/lldb/test/API/macosx/profile_vrs_detach/TestDetachVrsProfile.py
index 0d8e23af98636e..c2fa837ed01b87 100644
--- a/lldb/test/API/macosx/profile_vrs_detach/TestDetachVrsProfile.py
+++ b/lldb/test/API/macosx/profile_vrs_detach/TestDetachVrsProfile.py
@@ -49,7 +49,7 @@ def do_profile_and_detach(self):
threads = lldbutil.continue_to_breakpoint(process, bkpt)
self.assertEqual(len(threads), 1, "Hit our breakpoint again.")
str = process.GetAsyncProfileData(1000)
- self.assertTrue(len(str) > 0, "Got some profile data")
+ self.assertGreater(len(str), 0, "Got some profile data")
# Now make the profiling interval very long and try to detach.
interp.HandleCommand(
diff --git a/lldb/test/API/macosx/queues/TestQueues.py b/lldb/test/API/macosx/queues/TestQueues.py
index ff384fc48f25f7..f2d15bb5ff15c5 100644
--- a/lldb/test/API/macosx/queues/TestQueues.py
+++ b/lldb/test/API/macosx/queues/TestQueues.py
@@ -35,8 +35,9 @@ def setUp(self):
self.main_source = "main.c"
def check_queue_for_valid_queue_id(self, queue):
- self.assertTrue(
- queue.GetQueueID() != 0,
+ self.assertNotEqual(
+ queue.GetQueueID(),
+ 0,
"Check queue %s for valid QueueID (got 0x%x)"
% (queue.GetName(), queue.GetQueueID()),
)
@@ -363,8 +364,8 @@ def queues_with_libBacktraceRecording(self):
"Skipped because libBacktraceRecording.dylib was not loaded into the process."
)
- self.assertTrue(
- process.GetNumQueues() >= 4, "Found the correct number of queues."
+ self.assertGreaterEqual(
+ process.GetNumQueues(), 4, "Found the correct number of queues."
)
queue_submittor_1 = lldb.SBQueue()
@@ -456,8 +457,9 @@ def queues_with_libBacktraceRecording(self):
"doing_the_work_2",
"queue 2's pending item #0 should be doing_the_work_2",
)
- self.assertTrue(
- queue_performer_2.GetPendingItemAtIndex(9999).IsValid() == False,
+ self.assertEqual(
+ queue_performer_2.GetPendingItemAtIndex(9999).IsValid(),
+ False,
"queue 2's pending item #9999 is invalid",
)
diff --git a/lldb/test/API/macosx/universal/TestUniversal.py b/lldb/test/API/macosx/universal/TestUniversal.py
index 8f5c4aa2a32c80..aecc8814b377eb 100644
--- a/lldb/test/API/macosx/universal/TestUniversal.py
+++ b/lldb/test/API/macosx/universal/TestUniversal.py
@@ -144,8 +144,8 @@ def test_process_attach_with_wrong_arch(self):
bkpt = target.BreakpointCreateBySourceRegex("sleep", lldb.SBFileSpec("main.c"))
self.assertTrue(bkpt.IsValid(), "Valid breakpoint")
- self.assertTrue(
- bkpt.GetNumLocations() >= 1, "Our main breakpoint has locations."
+ self.assertGreaterEqual(
+ bkpt.GetNumLocations(), 1, "Our main breakpoint has locations."
)
popen = self.spawnSubprocess(exe, ["keep_waiting"])
@@ -167,4 +167,4 @@ def test_process_attach_with_wrong_arch(self):
threads = lldbutil.continue_to_breakpoint(process, bkpt)
self.assertEqual(len(threads), 1)
thread = threads[0]
- self.assertTrue(thread.GetNumFrames() > 1, "We were able to backtrace.")
+ self.assertGreater(thread.GetNumFrames(), 1, "We were able to backtrace.")
diff --git a/lldb/test/API/python_api/event/TestEvents.py b/lldb/test/API/python_api/event/TestEvents.py
index 3017c86a113d7d..a15f4357f4f5f7 100644
--- a/lldb/test/API/python_api/event/TestEvents.py
+++ b/lldb/test/API/python_api/event/TestEvents.py
@@ -369,7 +369,7 @@ def test_shadow_listener(self):
# Now create a breakpoint on main.c by name 'c'.
bkpt1 = target.BreakpointCreateByName("c", "a.out")
self.trace("breakpoint:", bkpt1)
- self.assertTrue(bkpt1.GetNumLocations() == 1, VALID_BREAKPOINT)
+ self.assertEqual(bkpt1.GetNumLocations(), 1, VALID_BREAKPOINT)
self.primary_listener = lldb.SBListener("my listener")
self.shadow_listener = lldb.SBListener("shadow listener")
@@ -431,11 +431,11 @@ def test_shadow_listener(self):
main_spec = lldb.SBFileSpec("main.c")
bkpt2 = target.BreakpointCreateBySourceRegex("b.2. returns %d", main_spec)
- self.assertTrue(bkpt2.GetNumLocations() > 0, "BP2 worked")
+ self.assertGreater(bkpt2.GetNumLocations(), 0, "BP2 worked")
bkpt2.SetAutoContinue(True)
bkpt3 = target.BreakpointCreateBySourceRegex("a.3. returns %d", main_spec)
- self.assertTrue(bkpt3.GetNumLocations() > 0, "BP3 worked")
+ self.assertGreater(bkpt3.GetNumLocations(), 0, "BP3 worked")
state = lldb.eStateStopped
restarted = False
diff --git a/lldb/test/API/python_api/file_handle/TestFileHandle.py b/lldb/test/API/python_api/file_handle/TestFileHandle.py
index c235be4bdd5ee7..b38585577f6f62 100644
--- a/lldb/test/API/python_api/file_handle/TestFileHandle.py
+++ b/lldb/test/API/python_api/file_handle/TestFileHandle.py
@@ -682,25 +682,25 @@ def test_stdout_file(self):
def test_identity(self):
f = io.StringIO()
sbf = lldb.SBFile(f)
- self.assertTrue(f is sbf.GetFile())
+ self.assertIs(f, sbf.GetFile())
sbf.Close()
self.assertTrue(f.closed)
f = io.StringIO()
sbf = lldb.SBFile.Create(f, borrow=True)
- self.assertTrue(f is sbf.GetFile())
+ self.assertIs(f, sbf.GetFile())
sbf.Close()
self.assertFalse(f.closed)
with open(self.out_filename, "w") as f:
sbf = lldb.SBFile(f)
- self.assertTrue(f is sbf.GetFile())
+ self.assertIs(f, sbf.GetFile())
sbf.Close()
self.assertTrue(f.closed)
with open(self.out_filename, "w") as f:
sbf = lldb.SBFile.Create(f, borrow=True)
- self.assertFalse(f is sbf.GetFile())
+ self.assertIsNot(f, sbf.GetFile())
sbf.Write(b"foobar\n")
self.assertEqual(f.fileno(), sbf.GetFile().fileno())
sbf.Close()
@@ -711,7 +711,7 @@ def test_identity(self):
with open(self.out_filename, "wb") as f:
sbf = lldb.SBFile.Create(f, borrow=True, force_io_methods=True)
- self.assertTrue(f is sbf.GetFile())
+ self.assertIs(f, sbf.GetFile())
sbf.Write(b"foobar\n")
self.assertEqual(f.fileno(), sbf.GetFile().fileno())
sbf.Close()
@@ -722,7 +722,7 @@ def test_identity(self):
with open(self.out_filename, "wb") as f:
sbf = lldb.SBFile.Create(f, force_io_methods=True)
- self.assertTrue(f is sbf.GetFile())
+ self.assertIs(f, sbf.GetFile())
sbf.Write(b"foobar\n")
self.assertEqual(f.fileno(), sbf.GetFile().fileno())
sbf.Close()
diff --git a/lldb/test/API/python_api/findvalue_duplist/TestSBFrameFindValue.py b/lldb/test/API/python_api/findvalue_duplist/TestSBFrameFindValue.py
index f989eb5b574b3d..f8ab3a74df378a 100644
--- a/lldb/test/API/python_api/findvalue_duplist/TestSBFrameFindValue.py
+++ b/lldb/test/API/python_api/findvalue_duplist/TestSBFrameFindValue.py
@@ -25,7 +25,7 @@ def test_formatters_api(self):
breakpoint = target.BreakpointCreateBySourceRegex(
"Set breakpoint here", lldb.SBFileSpec("main.cpp")
)
- self.assertTrue(breakpoint.GetNumLocations() > 0, VALID_BREAKPOINT)
+ self.assertGreater(breakpoint.GetNumLocations(), 0, VALID_BREAKPOINT)
# Launch the process, and do not stop at the entry point.
process = target.LaunchSimple(None, None, self.get_process_working_directory())
diff --git a/lldb/test/API/python_api/format/TestFormat.py b/lldb/test/API/python_api/format/TestFormat.py
index db20f02ba1c1ef..625eadd86ffe84 100644
--- a/lldb/test/API/python_api/format/TestFormat.py
+++ b/lldb/test/API/python_api/format/TestFormat.py
@@ -19,6 +19,6 @@ def test_format(self):
self.assertTrue(error.Fail())
format = lldb.SBFormat("${frame.index}", error)
- self.assertIs(error.GetCString(), None)
+ self.assertIsNone(error.GetCString())
self.assertTrue(format)
self.assertTrue(error.Success())
diff --git a/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py b/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py
index 8a811d25dac538..7e802f92da352a 100644
--- a/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py
+++ b/lldb/test/API/python_api/formatters/TestFormattersSBAPI.py
@@ -192,7 +192,7 @@ def cleanup():
)
self.assertTrue(foo_var.IsValid(), "could not find foo")
- self.assertFalse(foo_var.GetNumChildren() == 2, "still seeing synthetic value")
+ self.assertNotEqual(foo_var.GetNumChildren(), 2, "still seeing synthetic value")
filter = lldb.SBTypeFilter(0)
filter.AppendExpressionPath("A")
@@ -457,9 +457,8 @@ def cleanup():
"frame variable e2", substrs=["I am an empty Empty2 {}"], matching=False
)
- self.assertTrue(
- self.dbg.GetCategory(lldb.eLanguageTypeObjC) is not None,
- "ObjC category is None",
+ self.assertIsNotNone(
+ self.dbg.GetCategory(lldb.eLanguageTypeObjC), "ObjC category is None"
)
def test_force_synth_off(self):
@@ -518,8 +517,8 @@ def cleanup():
int_vector = frame.FindVariable("int_vector")
if self.TraceOn():
print(int_vector)
- self.assertFalse(
- int_vector.GetNumChildren() == 0, '"physical" vector is not empty'
+ self.assertNotEqual(
+ int_vector.GetNumChildren(), 0, '"physical" vector is not empty'
)
self.runCmd("settings set target.enable-synthetic-value true")
diff --git a/lldb/test/API/python_api/frame/get-variables/TestGetVariables.py b/lldb/test/API/python_api/frame/get-variables/TestGetVariables.py
index 79714f6fd56c1d..782edfa3c5e0d7 100644
--- a/lldb/test/API/python_api/frame/get-variables/TestGetVariables.py
+++ b/lldb/test/API/python_api/frame/get-variables/TestGetVariables.py
@@ -56,9 +56,9 @@ def test(self):
breakpoint2 = target.BreakpointCreateByLocation(self.source, line2)
breakpoint3 = target.BreakpointCreateByLocation(self.source, line3)
- self.assertTrue(breakpoint1.GetNumLocations() >= 1, PROCESS_IS_VALID)
- self.assertTrue(breakpoint2.GetNumLocations() >= 1, PROCESS_IS_VALID)
- self.assertTrue(breakpoint3.GetNumLocations() >= 1, PROCESS_IS_VALID)
+ self.assertGreaterEqual(breakpoint1.GetNumLocations(), 1, PROCESS_IS_VALID)
+ self.assertGreaterEqual(breakpoint2.GetNumLocations(), 1, PROCESS_IS_VALID)
+ self.assertGreaterEqual(breakpoint3.GetNumLocations(), 1, PROCESS_IS_VALID)
# Register our shared libraries for remote targets so they get
# automatically uploaded
diff --git a/lldb/test/API/python_api/module_section/TestModuleAndSection.py b/lldb/test/API/python_api/module_section/TestModuleAndSection.py
index 8a83740b06732c..96b53563d5dfa2 100644
--- a/lldb/test/API/python_api/module_section/TestModuleAndSection.py
+++ b/lldb/test/API/python_api/module_section/TestModuleAndSection.py
@@ -17,7 +17,7 @@ def test_module_and_section(self):
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
- self.assertTrue(target.GetNumModules() > 0)
+ self.assertGreater(target.GetNumModules(), 0)
# Hide stdout if not running with '-t' option.
if not self.TraceOn():
@@ -62,7 +62,7 @@ def test_module_and_section_boundary_condition(self):
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
- self.assertTrue(target.GetNumModules() > 0)
+ self.assertGreater(target.GetNumModules(), 0)
# Hide stdout if not running with '-t' option.
if not self.TraceOn():
@@ -102,7 +102,7 @@ def test_module_compile_unit_iter(self):
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
- self.assertTrue(target.GetNumModules() > 0)
+ self.assertGreater(target.GetNumModules(), 0)
# Hide stdout if not running with '-t' option.
if not self.TraceOn():
diff --git a/lldb/test/API/python_api/process/TestProcessAPI.py b/lldb/test/API/python_api/process/TestProcessAPI.py
index 65330e5163f72c..0b857fb033f1e2 100644
--- a/lldb/test/API/python_api/process/TestProcessAPI.py
+++ b/lldb/test/API/python_api/process/TestProcessAPI.py
@@ -324,7 +324,7 @@ def test_remote_launch(self):
if self.TraceOn():
print("process state:", state_type_to_str(process.GetState()))
- self.assertTrue(process.GetState() != lldb.eStateConnected)
+ self.assertNotEqual(process.GetState(), lldb.eStateConnected)
error = lldb.SBError()
success = process.RemoteLaunch(
diff --git a/lldb/test/API/python_api/process/io/TestProcessIO.py b/lldb/test/API/python_api/process/io/TestProcessIO.py
index 381b06e422aff7..5bb91d2758312d 100644
--- a/lldb/test/API/python_api/process/io/TestProcessIO.py
+++ b/lldb/test/API/python_api/process/io/TestProcessIO.py
@@ -175,7 +175,7 @@ def run_process(self, put_stdin):
self.breakpoint = self.target.BreakpointCreateBySourceRegex(
"Set breakpoint here", lldb.SBFileSpec("main.c")
)
- self.assertTrue(self.breakpoint.GetNumLocations() > 0, VALID_BREAKPOINT)
+ self.assertGreater(self.breakpoint.GetNumLocations(), 0, VALID_BREAKPOINT)
# Launch the process, and do not stop at the entry point.
error = lldb.SBError()
@@ -223,11 +223,7 @@ def check_process_output(self, output, error):
for line in self.lines:
check_line = "input line to stdout: %s" % (line)
- self.assertTrue(
- check_line in output, "verify stdout line shows up in STDOUT"
- )
+ self.assertIn(check_line, output, "verify stdout line shows up in STDOUT")
for line in self.lines:
check_line = "input line to stderr: %s" % (line)
- self.assertTrue(
- check_line in error, "verify stderr line shows up in STDERR"
- )
+ self.assertIn(check_line, error, "verify stderr line shows up in STDERR")
diff --git a/lldb/test/API/python_api/sbdata/TestSBData.py b/lldb/test/API/python_api/sbdata/TestSBData.py
index c0db11d4e53ff8..ef87d00f8240a8 100644
--- a/lldb/test/API/python_api/sbdata/TestSBData.py
+++ b/lldb/test/API/python_api/sbdata/TestSBData.py
@@ -90,8 +90,8 @@ def test_with_run_command(self):
self.assertTrue(
(low == 9 and high == 0) or (low == 0 and high == 9), "foo[0].b == 9"
)
- self.assertTrue(
- fabs(data.GetFloat(error, offset) - 3.14) < 1, "foo[0].c == 3.14"
+ self.assertLess(
+ fabs(data.GetFloat(error, offset) - 3.14), 1, "foo[0].c == 3.14"
)
self.assertSuccess(error)
offset += 4
@@ -151,7 +151,7 @@ def test_with_run_command(self):
self.assertEqual(data.uint32[0], 8, "then foo[1].a == 8")
self.assertEqual(data.uint32[1], 7, "then foo[1].b == 7")
# exploiting that sizeof(uint32) == sizeof(float)
- self.assertTrue(fabs(data.float[2] - 3.14) < 1, "foo[1].c == 3.14")
+ self.assertLess(fabs(data.float[2] - 3.14), 1, "foo[1].c == 3.14")
self.runCmd("n")
@@ -160,8 +160,8 @@ def test_with_run_command(self):
offset += 4
self.assert_data(data.GetUnsignedInt32, offset, 7)
offset += 4
- self.assertTrue(
- fabs(data.GetFloat(error, offset) - 3.14) < 1, "foo[1].c == 3.14"
+ self.assertLess(
+ fabs(data.GetFloat(error, offset) - 3.14), 1, "foo[1].c == 3.14"
)
self.assertSuccess(error)
@@ -172,8 +172,8 @@ def test_with_run_command(self):
offset += 4
self.assert_data(data.GetUnsignedInt32, offset, 7)
offset += 4
- self.assertTrue(
- fabs(data.GetFloat(error, offset) - 6.28) < 1, "foo[1].c == 6.28"
+ self.assertLess(
+ fabs(data.GetFloat(error, offset) - 6.28), 1, "foo[1].c == 6.28"
)
self.assertSuccess(error)
@@ -187,14 +187,14 @@ def test_with_run_command(self):
offset += 4
self.assert_data(data.GetUnsignedInt32, offset, 2)
offset += 4
- self.assertTrue(fabs(data.GetFloat(error, offset) - 3) < 1, "barfoo[0].c == 3")
+ self.assertLess(fabs(data.GetFloat(error, offset) - 3), 1, "barfoo[0].c == 3")
self.assertSuccess(error)
offset += 4
self.assert_data(data.GetUnsignedInt32, offset, 4)
offset += 4
self.assert_data(data.GetUnsignedInt32, offset, 5)
offset += 4
- self.assertTrue(fabs(data.GetFloat(error, offset) - 6) < 1, "barfoo[1].c == 6")
+ self.assertLess(fabs(data.GetFloat(error, offset) - 6), 1, "barfoo[1].c == 6")
self.assertSuccess(error)
new_object = barfoo.CreateValueFromData(
@@ -332,16 +332,16 @@ def test_with_run_command(self):
data2 = lldb.SBData.CreateDataFromDoubleArray(
process.GetByteOrder(), process.GetAddressByteSize(), [3.14, 6.28, 2.71]
)
- self.assertTrue(
- fabs(data2.GetDouble(error, 0) - 3.14) < 0.5, "double data2[0] = 3.14"
+ self.assertLess(
+ fabs(data2.GetDouble(error, 0) - 3.14), 0.5, "double data2[0] = 3.14"
)
self.assertSuccess(error)
- self.assertTrue(
- fabs(data2.GetDouble(error, 8) - 6.28) < 0.5, "double data2[1] = 6.28"
+ self.assertLess(
+ fabs(data2.GetDouble(error, 8) - 6.28), 0.5, "double data2[1] = 6.28"
)
self.assertSuccess(error)
- self.assertTrue(
- fabs(data2.GetDouble(error, 16) - 2.71) < 0.5, "double data2[2] = 2.71"
+ self.assertLess(
+ fabs(data2.GetDouble(error, 16) - 2.71), 0.5, "double data2[2] = 2.71"
)
self.assertSuccess(error)
@@ -380,8 +380,9 @@ def test_with_run_command(self):
data2.uint64[4], 5, "read_data_helper failure: set data2[4] = 5"
)
- self.assertTrue(
- data2.uint64[0:2] == [1, 2],
+ self.assertEqual(
+ data2.uint64[0:2],
+ [1, 2],
"read_data_helper failure: set data2[0:2] = [1,2]",
)
@@ -417,26 +418,29 @@ def test_with_run_command(self):
)
data2.SetDataFromDoubleArray([3.14, 6.28, 2.71])
- self.assertTrue(
- fabs(data2.GetDouble(error, 0) - 3.14) < 0.5, "set double data2[0] = 3.14"
+ self.assertLess(
+ fabs(data2.GetDouble(error, 0) - 3.14), 0.5, "set double data2[0] = 3.14"
)
- self.assertTrue(
- fabs(data2.GetDouble(error, 8) - 6.28) < 0.5, "set double data2[1] = 6.28"
+ self.assertLess(
+ fabs(data2.GetDouble(error, 8) - 6.28), 0.5, "set double data2[1] = 6.28"
)
- self.assertTrue(
- fabs(data2.GetDouble(error, 16) - 2.71) < 0.5, "set double data2[2] = 2.71"
+ self.assertLess(
+ fabs(data2.GetDouble(error, 16) - 2.71), 0.5, "set double data2[2] = 2.71"
)
- self.assertTrue(
- fabs(data2.double[0] - 3.14) < 0.5,
+ self.assertLess(
+ fabs(data2.double[0] - 3.14),
+ 0.5,
"read_data_helper failure: set double data2[0] = 3.14",
)
- self.assertTrue(
- fabs(data2.double[1] - 6.28) < 0.5,
+ self.assertLess(
+ fabs(data2.double[1] - 6.28),
+ 0.5,
"read_data_helper failure: set double data2[1] = 6.28",
)
- self.assertTrue(
- fabs(data2.double[2] - 2.71) < 0.5,
+ self.assertLess(
+ fabs(data2.double[2] - 2.71),
+ 0.5,
"read_data_helper failure: set double data2[2] = 2.71",
)
@@ -452,7 +456,8 @@ def assert_data(self, func, arg, expected):
"%s(error, %s) did not succeed: %s"
% (func.__name__, arg, stream.GetData()),
)
- self.assertTrue(
- expected == result,
+ self.assertEqual(
+ expected,
+ result,
"%s(error, %s) == %s != %s" % (func.__name__, arg, result, expected),
)
diff --git a/lldb/test/API/python_api/sbmodule/TestSBModule.py b/lldb/test/API/python_api/sbmodule/TestSBModule.py
index 69a20b32a058a7..c04e2fa55e8cff 100644
--- a/lldb/test/API/python_api/sbmodule/TestSBModule.py
+++ b/lldb/test/API/python_api/sbmodule/TestSBModule.py
@@ -51,7 +51,7 @@ def test_module_is_file_backed(self):
)
self.assertTrue(error.Success() and process, PROCESS_IS_VALID)
main_module = target.FindModule(lldb.SBFileSpec("a.out"))
- self.assertTrue(main_module is not None)
+ self.assertIsNotNone(main_module)
self.assertFalse(
main_module.IsFileBacked(),
"The module should not be backed by a file on disk.",
diff --git a/lldb/test/API/python_api/target/TestTargetAPI.py b/lldb/test/API/python_api/target/TestTargetAPI.py
index 63d34340a8836e..2e8d6a5b1e53f6 100644
--- a/lldb/test/API/python_api/target/TestTargetAPI.py
+++ b/lldb/test/API/python_api/target/TestTargetAPI.py
@@ -112,7 +112,7 @@ def test_get_ABIName(self):
target = self.create_simple_target("b.out")
abi_pre_launch = target.GetABIName()
- self.assertTrue(len(abi_pre_launch) != 0, "Got an ABI string")
+ self.assertNotEqual(len(abi_pre_launch), 0, "Got an ABI string")
breakpoint = target.BreakpointCreateByLocation("main.c", self.line_main)
self.assertTrue(breakpoint, VALID_BREAKPOINT)
diff --git a/lldb/test/API/python_api/type/TestTypeList.py b/lldb/test/API/python_api/type/TestTypeList.py
index 8d82f7b0228748..e75affd6522115 100644
--- a/lldb/test/API/python_api/type/TestTypeList.py
+++ b/lldb/test/API/python_api/type/TestTypeList.py
@@ -54,7 +54,7 @@ def test(self):
% type_list.GetSize()
)
# a second Task make be scared up by the Objective-C runtime
- self.assertTrue(len(type_list) >= 1)
+ self.assertGreaterEqual(len(type_list), 1)
for type in type_list:
self.assertTrue(type)
self.DebugSBType(type)
@@ -133,7 +133,7 @@ def test(self):
self.DebugSBType(union_type)
# Check that we don't find indirectly nested types
- self.assertTrue(enum_type.size == 1)
+ self.assertEqual(enum_type.size, 1)
invalid_type = task_type.FindDirectNestedType("E2")
self.assertFalse(invalid_type)
diff --git a/lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py b/lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py
index 07250eb6a4830f..7d9aa76b9eef93 100644
--- a/lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py
+++ b/lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py
@@ -128,7 +128,7 @@ def test_change_value(self):
"Val - 12345 Mine - 55, 98765, 55555555. Ptr - 66, 98765, 66666666"
)
stdout = process.GetSTDOUT(1000)
- self.assertTrue(expected_value in stdout, "STDOUT showed changed values.")
+ self.assertIn(expected_value, stdout, "STDOUT showed changed values.")
# Finally, change the stack pointer to 0, and we should not make it to
# our end breakpoint.
@@ -150,8 +150,8 @@ def test_change_value(self):
self.assertState(process.GetState(), lldb.eStateStopped)
thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
- self.assertTrue(
- thread is None,
+ self.assertIsNone(
+ thread,
"We should not have managed to hit our second breakpoint with sp == 1",
)
diff --git a/lldb/test/API/python_api/value/change_values/libcxx/atomic/TestChangeValue.py b/lldb/test/API/python_api/value/change_values/libcxx/atomic/TestChangeValue.py
index 757965f680a673..c429eea501e2bf 100644
--- a/lldb/test/API/python_api/value/change_values/libcxx/atomic/TestChangeValue.py
+++ b/lldb/test/API/python_api/value/change_values/libcxx/atomic/TestChangeValue.py
@@ -47,4 +47,4 @@ def test(self):
result = inner_val.SetValueFromCString("42")
self.assertTrue(result, "Setting val returned True.")
result = inner_val.GetValueAsUnsigned()
- self.assertTrue(result == 42, "Got correct value (42)")
+ self.assertEqual(result, 42, "Got correct value (42)")
diff --git a/lldb/test/API/python_api/value/change_values/libcxx/map/TestChangeMapValue.py b/lldb/test/API/python_api/value/change_values/libcxx/map/TestChangeMapValue.py
index 2cbfa04babb184..cd445e8c772de1 100644
--- a/lldb/test/API/python_api/value/change_values/libcxx/map/TestChangeMapValue.py
+++ b/lldb/test/API/python_api/value/change_values/libcxx/map/TestChangeMapValue.py
@@ -44,10 +44,10 @@ def test(self):
self.assertTrue(val_value.IsValid(), "Got the SBValue for val")
pair0 = val_value.GetChildMemberWithName("[0]")
self.assertTrue(pair0.IsValid(), "Got the SBValue for [0]")
- self.assertTrue(pair0.GetNumChildren() == 2, "Got 2 children")
+ self.assertEqual(pair0.GetNumChildren(), 2, "Got 2 children")
pair0_second = pair0.GetChildMemberWithName("second")
self.assertTrue(pair0_second.IsValid(), "Got the SBValue for [0].second")
result = pair0_second.SetValueFromCString("12345")
self.assertTrue(result, "Setting val returned True.")
result = pair0_second.GetValueAsUnsigned()
- self.assertTrue(result == 12345, "Got correct value (12345)")
+ self.assertEqual(result, 12345, "Got correct value (12345)")
diff --git a/lldb/test/API/python_api/watchpoint/TestWatchpointIter.py b/lldb/test/API/python_api/watchpoint/TestWatchpointIter.py
index 5702b9934f329d..f7c22fb9c2bd62 100644
--- a/lldb/test/API/python_api/watchpoint/TestWatchpointIter.py
+++ b/lldb/test/API/python_api/watchpoint/TestWatchpointIter.py
@@ -66,7 +66,7 @@ def test_watch_iter(self):
self.assertEqual(target.GetNumWatchpoints(), 1)
self.assertTrue(watchpoint.IsEnabled())
watch_id = watchpoint.GetID()
- self.assertTrue(watch_id != 0)
+ self.assertNotEqual(watch_id, 0)
# Continue. Expect the program to stop due to the variable being
# written to.
diff --git a/lldb/test/API/source-manager/TestSourceManager.py b/lldb/test/API/source-manager/TestSourceManager.py
index 7569bb79257d16..eab8924d108146 100644
--- a/lldb/test/API/source-manager/TestSourceManager.py
+++ b/lldb/test/API/source-manager/TestSourceManager.py
@@ -259,7 +259,7 @@ def test_modify_source_file_while_debugging(self):
m = re.search("^\[(\d+)\].*// Set break point at this line.", output)
if not m:
self.fail("Fail to display source level breakpoints")
- self.assertTrue(int(m.group(1)) > 0)
+ self.assertGreater(int(m.group(1)), 0)
# Modify content
self.modify_content()
diff --git a/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py b/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py
index 3781f651325d3b..13190a50954ad7 100644
--- a/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py
+++ b/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py
@@ -70,4 +70,4 @@ def test_core_file_source_mapping(self):
source_map = [["/home/labath/test", current_dir]]
self.attach(exe_file, coreFile=core_file, sourceMap=source_map)
- self.assertTrue(current_dir in self.get_stackFrames()[0]["source"]["path"])
+ self.assertIn(current_dir, self.get_stackFrames()[0]["source"]["path"])
diff --git a/lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py b/lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py
index cb4e946c52112d..1b96ea71659f97 100644
--- a/lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py
+++ b/lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py
@@ -31,11 +31,11 @@ def test_disassemble(self):
self.continue_to_next_stop()
pc_assembly = self.disassemble(frameIndex=0)
- self.assertTrue("location" in pc_assembly, "Source location missing.")
- self.assertTrue("instruction" in pc_assembly, "Assembly instruction missing.")
+ self.assertIn("location", pc_assembly, "Source location missing.")
+ self.assertIn("instruction", pc_assembly, "Assembly instruction missing.")
# The calling frame (qsort) is coming from a system library, as a result
# we should not have a source location.
qsort_assembly = self.disassemble(frameIndex=1)
- self.assertFalse("location" in qsort_assembly, "Source location not expected.")
- self.assertTrue("instruction" in pc_assembly, "Assembly instruction missing.")
+ self.assertNotIn("location", qsort_assembly, "Source location not expected.")
+ self.assertIn("instruction", pc_assembly, "Assembly instruction missing.")
diff --git a/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py b/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
index a72571898ab500..f79a31988dc6ce 100644
--- a/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
+++ b/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py
@@ -78,7 +78,7 @@ def test_runInTerminal(self):
# We verify we actually stopped inside the loop
counter = int(self.dap_server.get_local_variable_value("counter"))
- self.assertTrue(counter > 0)
+ self.assertGreater(counter, 0)
# We verify we were able to set the launch arguments
argc = int(self.dap_server.get_local_variable_value("argc"))
@@ -122,7 +122,7 @@ def test_missingArgInRunInTerminalLauncher(self):
capture_output=True,
universal_newlines=True,
)
- self.assertTrue(proc.returncode != 0)
+ self.assertNotEqual(proc.returncode, 0)
self.assertIn(
'"--launch-target" requires "--comm-file" to be specified', proc.stderr
)
diff --git a/lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py b/lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py
index a51b2173f027dc..70526cc715388d 100644
--- a/lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py
+++ b/lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py
@@ -83,8 +83,8 @@ def test_stackTrace(self):
# Verify we get all stack frames with no arguments
(stackFrames, totalFrames) = self.get_stackFrames_and_totalFramesCount()
frameCount = len(stackFrames)
- self.assertTrue(
- frameCount >= 20, "verify we get at least 20 frames for all frames"
+ self.assertGreaterEqual(
+ frameCount, 20, "verify we get at least 20 frames for all frames"
)
self.assertEqual(
totalFrames, frameCount, "verify we get correct value for totalFrames count"
diff --git a/lldb/test/API/tools/lldb-dap/terminated-event/TestDAP_terminatedEvent.py b/lldb/test/API/tools/lldb-dap/terminated-event/TestDAP_terminatedEvent.py
index 80a15dd4c9ab70..ff5081a41424fc 100644
--- a/lldb/test/API/tools/lldb-dap/terminated-event/TestDAP_terminatedEvent.py
+++ b/lldb/test/API/tools/lldb-dap/terminated-event/TestDAP_terminatedEvent.py
@@ -45,16 +45,16 @@ def test_terminated_event(self):
self.continue_to_exit()
statistics = self.dap_server.wait_for_terminated()["statistics"]
- self.assertTrue(statistics["totalDebugInfoByteSize"] > 0)
- self.assertTrue(statistics["totalDebugInfoEnabled"] > 0)
- self.assertTrue(statistics["totalModuleCountHasDebugInfo"] > 0)
+ self.assertGreater(statistics["totalDebugInfoByteSize"], 0)
+ self.assertGreater(statistics["totalDebugInfoEnabled"], 0)
+ self.assertGreater(statistics["totalModuleCountHasDebugInfo"], 0)
self.assertIsNotNone(statistics["memory"])
self.assertNotIn("modules", statistics.keys())
# lldb-dap debugs one target at a time
target = json.loads(statistics["targets"])[0]
- self.assertTrue(target["totalBreakpointResolveTime"] > 0)
+ self.assertGreater(target["totalBreakpointResolveTime"], 0)
breakpoints = target["breakpoints"]
self.assertIn(
diff --git a/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py b/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py
index 1f7dd7b2c42a89..d886d0776ce58b 100644
--- a/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py
+++ b/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py
@@ -58,14 +58,14 @@ def verify_values(self, verify_dict, actual, varref_dict=None, expression=None):
for key in verify:
contains_array = verify[key]
actual_value = actual[key]
- self.assertTrue(isinstance(contains_array, list))
+ self.assertIsInstance(contains_array, list)
for verify_value in contains_array:
self.assertIn(verify_value, actual_value)
if "missing" in verify_dict:
missing = verify_dict["missing"]
for key in missing:
- self.assertTrue(
- key not in actual, 'key "%s" is not expected in %s' % (key, actual)
+ self.assertNotIn(
+ key, actual, 'key "%s" is not expected in %s' % (key, actual)
)
hasVariablesReference = "variablesReference" in actual
varRef = None
@@ -727,8 +727,8 @@ def test_registers(self):
if reg["name"] == pc_name:
value = reg["value"]
self.assertTrue(value.startswith("0x"))
- self.assertTrue("a.out`main + " in value)
- self.assertTrue("at main.cpp:" in value)
+ self.assertIn("a.out`main + ", value)
+ self.assertIn("at main.cpp:", value)
@no_debug_info_test
@skipUnlessDarwin
diff --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py b/lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py
index 38900353290bb3..5aa790b1c97e54 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py
@@ -17,7 +17,7 @@ def test_attach_with_vAttach(self):
# Make sure the target process has been launched.
inferior = procs.get("inferior")
self.assertIsNotNone(inferior)
- self.assertTrue(inferior.pid > 0)
+ self.assertGreater(inferior.pid, 0)
self.assertTrue(lldbgdbserverutils.process_is_running(inferior.pid, True))
# Add attach packets.
diff --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteAuxvSupport.py b/lldb/test/API/tools/lldb-server/TestGdbRemoteAuxvSupport.py
index 999d8ce9d467cf..25ad600c292d14 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteAuxvSupport.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteAuxvSupport.py
@@ -117,8 +117,8 @@ def test_auxv_keys_look_valid(self):
# small (usually smaller than 50), they can sometimes be larger.
self.trace("auxv dict: {}".format(auxv_dict))
for auxv_key in auxv_dict:
- self.assertTrue(auxv_key >= 1)
- self.assertTrue(auxv_key <= 2500)
+ self.assertGreaterEqual(auxv_key, 1)
+ self.assertLessEqual(auxv_key, 2500)
@skipIfWindows
@expectedFailureNetBSD
diff --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py b/lldb/test/API/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py
index 474fd7f2d9993d..ddddc9ee72fcf0 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py
@@ -44,7 +44,7 @@ def stop_notification_contains_generic_register(self, generic_register_name):
# notification.
expedited_registers = self.gather_expedited_registers()
self.assertIsNotNone(expedited_registers)
- self.assertTrue(len(expedited_registers) > 0)
+ self.assertGreater(len(expedited_registers), 0)
# Gather target register infos.
reg_infos = self.gather_register_infos()
@@ -67,7 +67,7 @@ def test_stop_notification_contains_any_registers(self):
# notification.
expedited_registers = self.gather_expedited_registers()
# Verify we have at least one expedited register.
- self.assertTrue(len(expedited_registers) > 0)
+ self.assertGreater(len(expedited_registers), 0)
def test_stop_notification_contains_no_duplicate_registers(self):
self.build()
@@ -113,7 +113,7 @@ def test_stop_notification_contains_vg_register(self):
# notification.
expedited_registers = self.gather_expedited_registers()
self.assertIsNotNone(expedited_registers)
- self.assertTrue(len(expedited_registers) > 0)
+ self.assertGreater(len(expedited_registers), 0)
# Gather target register infos.
reg_infos = self.gather_register_infos()
diff --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteRegisterState.py b/lldb/test/API/tools/lldb-server/TestGdbRemoteRegisterState.py
index 176dd18b18a224..39aa473322a9f3 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteRegisterState.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteRegisterState.py
@@ -38,7 +38,7 @@ def grp_register_save_restore_works(self, with_suffix):
for reg_info in reg_infos
if self.is_bit_flippable_register(reg_info)
]
- self.assertTrue(len(gpr_reg_infos) > 0)
+ self.assertGreater(len(gpr_reg_infos), 0)
# Gather thread info.
if with_suffix:
@@ -77,7 +77,7 @@ def grp_register_save_restore_works(self, with_suffix):
successful_writes, failed_writes
)
)
- self.assertTrue(successful_writes > 0)
+ self.assertGreater(successful_writes, 0)
flipped_reg_values = self.read_register_values(
gpr_reg_infos, endian, thread_id=thread_id
diff --git a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
index 46ed59808eb66e..32b36bc04c1a3a 100644
--- a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
+++ b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
@@ -214,7 +214,7 @@ def test_qRegisterInfo_contains_at_least_one_register_set(self):
register_sets = {
reg_info["set"]: 1 for reg_info in reg_infos if "set" in reg_info
}
- self.assertTrue(len(register_sets) >= 1)
+ self.assertGreaterEqual(len(register_sets), 1)
def targetHasAVX(self):
triple = self.dbg.GetSelectedPlatform().GetTriple()
@@ -344,7 +344,7 @@ def test_p_returns_correct_data_size_for_each_qRegisterInfo_launch(self):
# Gather register info entries.
reg_infos = self.parse_register_info_packets(context)
self.assertIsNotNone(reg_infos)
- self.assertTrue(len(reg_infos) > 0)
+ self.assertGreater(len(reg_infos), 0)
byte_order = self.get_target_byte_order()
@@ -1072,7 +1072,7 @@ def get_qSupported_dict(self, features=[]):
def test_qSupported_returns_known_stub_features(self):
supported_dict = self.get_qSupported_dict()
self.assertIsNotNone(supported_dict)
- self.assertTrue(len(supported_dict) > 0)
+ self.assertGreater(len(supported_dict), 0)
def test_qSupported_auvx(self):
expected = (
@@ -1267,7 +1267,7 @@ def test_P_writes_all_gpr_registers(self):
for reg_info in reg_infos
if self.is_bit_flippable_register(reg_info)
]
- self.assertTrue(len(gpr_reg_infos) > 0)
+ self.assertGreater(len(gpr_reg_infos), 0)
# Write flipped bit pattern of existing value to each register.
(successful_writes, failed_writes) = self.flip_all_bits_in_each_register_value(
@@ -1278,7 +1278,7 @@ def test_P_writes_all_gpr_registers(self):
successful_writes, failed_writes
)
)
- self.assertTrue(successful_writes > 0)
+ self.assertGreater(successful_writes, 0)
# Note: as of this moment, a hefty number of the GPR writes are failing
# with E32 (everything except rax-rdx, rdi, rsi, rbp).
@@ -1310,7 +1310,7 @@ def test_P_and_p_thread_suffix_work(self):
reg_index = self.select_modifiable_register(reg_infos)
self.assertIsNotNone(reg_index)
reg_byte_size = int(reg_infos[reg_index]["bitsize"]) // 8
- self.assertTrue(reg_byte_size > 0)
+ self.assertGreater(reg_byte_size, 0)
expected_reg_values = []
register_increment = 1
diff --git a/lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py b/lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py
index 24548100de7d2e..f4c31fe2f5c076 100644
--- a/lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py
+++ b/lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py
@@ -26,7 +26,7 @@ def _set_up_inferior(self):
def _launch_inferior(self, args):
inferior = self.spawnSubprocess(self.getBuildArtifact(self._exe_to_run), args)
self.assertIsNotNone(inferior)
- self.assertTrue(inferior.pid > 0)
+ self.assertGreater(inferior.pid, 0)
self.assertTrue(lldbgdbserverutils.process_is_running(inferior.pid, True))
return inferior
diff --git a/lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py b/lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py
index 2a7f1f02155ab0..bd78a83c656554 100644
--- a/lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py
+++ b/lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py
@@ -46,7 +46,7 @@ def test_g_target_xml_returns_correct_data(self):
self.assertIsNotNone(feature)
target_xml_registers = feature.findall("reg")
- self.assertTrue(len(target_xml_registers) > 0)
+ self.assertGreater(len(target_xml_registers), 0)
# registers info collected by qRegisterInfo
self.add_register_info_collection_packets()
More information about the lldb-commits
mailing list