[Lldb-commits] [lldb] [lldb][test] Modernize asserts (PR #82503)

via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 21 08:21:27 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Jordan Rupprecht (rupprecht)

<details>
<summary>Changes</summary>

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`.

---

Patch is 112.26 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/82503.diff


99 Files Affected:

- (modified) lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py (+1-1) 
- (modified) lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py (+2-2) 
- (modified) lldb/test/API/commands/expression/completion-crash-invalid-iterator/TestInvalidIteratorCompletionCrash.py (+1-1) 
- (modified) lldb/test/API/commands/expression/fixits/TestFixIts.py (+4-4) 
- (modified) lldb/test/API/commands/expression/test/TestExprs.py (+1-1) 
- (modified) lldb/test/API/commands/expression/unwind_expression/TestUnwindExpression.py (+3-2) 
- (modified) lldb/test/API/commands/register/register/aarch64_sme_z_registers/save_restore/TestSMEZRegistersSaveRestore.py (+1-1) 
- (modified) lldb/test/API/commands/register/register/aarch64_sme_z_registers/za_dynamic_resize/TestZAThreadedDynamic.py (+1-1) 
- (modified) lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py (+1-1) 
- (modified) lldb/test/API/commands/session/save/TestSessionSave.py (+1-1) 
- (modified) lldb/test/API/commands/statistics/basic/TestStats.py (+2-2) 
- (modified) lldb/test/API/commands/trace/TestTraceExport.py (+1-1) 
- (modified) lldb/test/API/commands/trace/TestTraceSave.py (+5-5) 
- (modified) lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py (+3-3) 
- (modified) lldb/test/API/functionalities/archives/TestBSDArchives.py (+6-4) 
- (modified) lldb/test/API/functionalities/asan/TestMemoryHistory.py (+3-3) 
- (modified) lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py (+12-8) 
- (modified) lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py (+3-1) 
- (modified) lldb/test/API/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py (+2-2) 
- (modified) lldb/test/API/functionalities/breakpoint/hardware_breakpoints/require_hw_breakpoints/TestRequireHWBreakpoints.py (+6-6) 
- (modified) lldb/test/API/functionalities/breakpoint/objc/TestObjCBreakpoints.py (+9-6) 
- (modified) lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py (+12-10) 
- (modified) lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py (+1-1) 
- (modified) lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py (+1-1) 
- (modified) lldb/test/API/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py (+14-10) 
- (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py (+5-5) 
- (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string_view/TestDataFormatterLibcxxStringView.py (+5-5) 
- (modified) lldb/test/API/functionalities/gdb_remote_client/TestMSP430MSPDebug.py (+6-5) 
- (modified) lldb/test/API/functionalities/multidebugger_commands/TestMultipleDebuggersCommands.py (+6-4) 
- (modified) lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py (+2-2) 
- (modified) lldb/test/API/functionalities/return-value/TestReturnValue.py (+3-2) 
- (modified) lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py (+1-3) 
- (modified) lldb/test/API/functionalities/signal/TestSendSignal.py (+2-2) 
- (modified) lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py (+2-2) 
- (modified) lldb/test/API/functionalities/signal/handle-segv/TestHandleSegv.py (+2-2) 
- (modified) lldb/test/API/functionalities/signal/raise/TestRaise.py (+4-4) 
- (modified) lldb/test/API/functionalities/step-avoids-no-debug/TestStepNoDebug.py (+3-2) 
- (modified) lldb/test/API/functionalities/step-avoids-regexp/TestStepAvoidsRegexp.py (+3-2) 
- (modified) lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py (+3-2) 
- (modified) lldb/test/API/functionalities/thread/break_after_join/TestBreakAfterJoin.py (+3-2) 
- (modified) lldb/test/API/functionalities/thread/create_during_step/TestCreateDuringStep.py (+6-4) 
- (modified) lldb/test/API/functionalities/thread/exit_during_break/TestExitDuringBreak.py (+3-2) 
- (modified) lldb/test/API/functionalities/thread/multi_break/TestMultipleBreakpoints.py (+3-2) 
- (modified) lldb/test/API/functionalities/thread/num_threads/TestNumThreads.py (+6-4) 
- (modified) lldb/test/API/functionalities/thread_plan/TestThreadPlanCommands.py (+6-6) 
- (modified) lldb/test/API/functionalities/tsan/basic/TestTsanBasic.py (+1-1) 
- (modified) lldb/test/API/functionalities/tsan/multiple/TestTsanMultiple.py (+1-1) 
- (modified) lldb/test/API/functionalities/unwind/aarch64_unwind_pac/TestAArch64UnwindPAC.py (+3-1) 
- (modified) lldb/test/API/lang/c/register_variables/TestRegisterVariables.py (+3-2) 
- (modified) lldb/test/API/lang/c/stepping/TestStepAndBreakpoints.py (+4-3) 
- (modified) lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py (+3-3) 
- (modified) lldb/test/API/lang/cpp/namespace/TestNamespace.py (+9-6) 
- (modified) lldb/test/API/lang/cpp/stl/TestSTL.py (+1-1) 
- (modified) lldb/test/API/lang/objc/foundation/TestFoundationDisassembly.py (+1-3) 
- (modified) lldb/test/API/lang/objc/objc-class-method/TestObjCClassMethod.py (+1-1) 
- (modified) lldb/test/API/lang/objc/objc-struct-argument/TestObjCStructArgument.py (+1-1) 
- (modified) lldb/test/API/lang/objc/objc-struct-return/TestObjCStructReturn.py (+1-1) 
- (modified) lldb/test/API/lang/objc/objc-super/TestObjCSuper.py (+1-1) 
- (modified) lldb/test/API/lang/objc/rdar-12408181/TestRdar12408181.py (+5-4) 
- (modified) lldb/test/API/lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py (+1-1) 
- (modified) lldb/test/API/linux/aarch64/tagged_memory_access/TestAArch64LinuxTaggedMemoryAccess.py (+1-3) 
- (modified) lldb/test/API/linux/aarch64/unwind_signal/TestUnwindSignal.py (+2-2) 
- (modified) lldb/test/API/lua_api/TestLuaAPI.py (+1-1) 
- (modified) lldb/test/API/macosx/function-starts/TestFunctionStarts.py (+3-3) 
- (modified) lldb/test/API/macosx/objc_exception_recognizer/TestObjCRecognizer.py (+2-2) 
- (modified) lldb/test/API/macosx/profile_vrs_detach/TestDetachVrsProfile.py (+1-1) 
- (modified) lldb/test/API/macosx/queues/TestQueues.py (+8-6) 
- (modified) lldb/test/API/macosx/universal/TestUniversal.py (+3-3) 
- (modified) lldb/test/API/python_api/event/TestEvents.py (+3-3) 
- (modified) lldb/test/API/python_api/file_handle/TestFileHandle.py (+6-6) 
- (modified) lldb/test/API/python_api/findvalue_duplist/TestSBFrameFindValue.py (+1-1) 
- (modified) lldb/test/API/python_api/format/TestFormat.py (+1-1) 
- (modified) lldb/test/API/python_api/formatters/TestFormattersSBAPI.py (+5-6) 
- (modified) lldb/test/API/python_api/frame/get-variables/TestGetVariables.py (+3-3) 
- (modified) lldb/test/API/python_api/module_section/TestModuleAndSection.py (+3-3) 
- (modified) lldb/test/API/python_api/process/TestProcessAPI.py (+1-1) 
- (modified) lldb/test/API/python_api/process/io/TestProcessIO.py (+3-7) 
- (modified) lldb/test/API/python_api/sbdata/TestSBData.py (+36-31) 
- (modified) lldb/test/API/python_api/sbmodule/TestSBModule.py (+1-1) 
- (modified) lldb/test/API/python_api/target/TestTargetAPI.py (+1-1) 
- (modified) lldb/test/API/python_api/type/TestTypeList.py (+2-2) 
- (modified) lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py (+3-3) 
- (modified) lldb/test/API/python_api/value/change_values/libcxx/atomic/TestChangeValue.py (+1-1) 
- (modified) lldb/test/API/python_api/value/change_values/libcxx/map/TestChangeMapValue.py (+2-2) 
- (modified) lldb/test/API/python_api/watchpoint/TestWatchpointIter.py (+1-1) 
- (modified) lldb/test/API/source-manager/TestSourceManager.py (+1-1) 
- (modified) lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py (+1-1) 
- (modified) lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py (+4-4) 
- (modified) lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py (+2-2) 
- (modified) lldb/test/API/tools/lldb-dap/stackTrace/TestDAP_stackTrace.py (+2-2) 
- (modified) lldb/test/API/tools/lldb-dap/terminated-event/TestDAP_terminatedEvent.py (+4-4) 
- (modified) lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py (+5-5) 
- (modified) lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py (+1-1) 
- (modified) lldb/test/API/tools/lldb-server/TestGdbRemoteAuxvSupport.py (+2-2) 
- (modified) lldb/test/API/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py (+3-3) 
- (modified) lldb/test/API/tools/lldb-server/TestGdbRemoteRegisterState.py (+2-2) 
- (modified) lldb/test/API/tools/lldb-server/TestLldbGdbServer.py (+6-6) 
- (modified) lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py (+1-1) 
- (modified) lldb/test/API/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py (+1-1) 


``````````diff
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...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/82503


More information about the lldb-commits mailing list