[lldb] Use assertIn/NotIn over assertTrue/False (NFC)

For improved failure messages, use `assertIn` over `assertTrue`.

Differential Revision: https://reviews.llvm.org/D96095
This commit is contained in:
Dave Lee 2021-02-02 16:24:03 -08:00
parent 4b5dbc7a3b
commit 3cc3762292
39 changed files with 101 additions and 101 deletions

View File

@ -69,7 +69,7 @@ class TestAllowJIT(TestBase):
# Again use it and ensure we fail:
result = frame.EvaluateExpression("call_me(10)", options)
self.assertTrue(result.GetError().Fail(), "expression failed with no JIT")
self.assertTrue("Can't evaluate the expression without a running target" in result.GetError().GetCString(), "Got right error")
self.assertIn("Can't evaluate the expression without a running target", result.GetError().GetCString(), "Got right error")
# Finally set the allow JIT value back to true and make sure that works:
options.SetAllowJIT(True)

View File

@ -64,28 +64,28 @@ class TestFrameVar(TestBase):
result = interp.HandleCommand("frame var -l", command_result)
self.assertEqual(result, lldb.eReturnStatusSuccessFinishResult, "frame var -a didn't succeed")
output = command_result.GetOutput()
self.assertTrue("argc" in output, "Args didn't find argc")
self.assertTrue("argv" in output, "Args didn't find argv")
self.assertTrue("test_var" not in output, "Args found a local")
self.assertTrue("g_var" not in output, "Args found a global")
self.assertIn("argc", output, "Args didn't find argc")
self.assertIn("argv", output, "Args didn't find argv")
self.assertNotIn("test_var", output, "Args found a local")
self.assertNotIn("g_var", output, "Args found a global")
# Just get locals:
result = interp.HandleCommand("frame var -a", command_result)
self.assertEqual(result, lldb.eReturnStatusSuccessFinishResult, "frame var -a didn't succeed")
output = command_result.GetOutput()
self.assertTrue("argc" not in output, "Locals found argc")
self.assertTrue("argv" not in output, "Locals found argv")
self.assertTrue("test_var" in output, "Locals didn't find test_var")
self.assertTrue("g_var" not in output, "Locals found a global")
self.assertNotIn("argc", output, "Locals found argc")
self.assertNotIn("argv", output, "Locals found argv")
self.assertIn("test_var", output, "Locals didn't find test_var")
self.assertNotIn("g_var", output, "Locals found a global")
# Get the file statics:
result = interp.HandleCommand("frame var -l -a -g", command_result)
self.assertEqual(result, lldb.eReturnStatusSuccessFinishResult, "frame var -a didn't succeed")
output = command_result.GetOutput()
self.assertTrue("argc" not in output, "Globals found argc")
self.assertTrue("argv" not in output, "Globals found argv")
self.assertTrue("test_var" not in output, "Globals found test_var")
self.assertTrue("g_var" in output, "Globals didn't find g_var")
self.assertNotIn("argc", output, "Globals found argc")
self.assertNotIn("argv", output, "Globals found argv")
self.assertNotIn("test_var", output, "Globals found test_var")
self.assertIn("g_var", output, "Globals didn't find g_var")

View File

@ -288,14 +288,14 @@ class BreakpointNames(TestBase):
name_list = lldb.SBStringList()
self.target.GetBreakpointNames(name_list)
for name_string in [self.bp_name_string, other_bp_name_string, cl_bp_name_string]:
self.assertTrue(name_string in name_list, "Didn't find %s in names"%(name_string))
self.assertIn(name_string, name_list, "Didn't find %s in names"%(name_string))
# Delete the name from the current target. Make sure that works and deletes the
# name from the breakpoint as well:
self.target.DeleteBreakpointName(self.bp_name_string)
name_list.Clear()
self.target.GetBreakpointNames(name_list)
self.assertTrue(self.bp_name_string not in name_list, "Didn't delete %s from a real target"%(self.bp_name_string))
self.assertNotIn(self.bp_name_string, name_list, "Didn't delete %s from a real target"%(self.bp_name_string))
# Also make sure the name got removed from breakpoints holding it:
self.assertFalse(bkpt.MatchesName(self.bp_name_string), "Didn't remove the name from the breakpoint.")
@ -305,7 +305,7 @@ class BreakpointNames(TestBase):
dummy_target.DeleteBreakpointName(self.bp_name_string)
name_list.Clear()
dummy_target.GetBreakpointNames(name_list)
self.assertTrue(self.bp_name_string not in name_list, "Didn't delete %s from the dummy target"%(self.bp_name_string))
self.assertNotIn(self.bp_name_string, name_list, "Didn't delete %s from the dummy target"%(self.bp_name_string))
# Also make sure the name got removed from breakpoints holding it:
self.assertFalse(bkpt.MatchesName(self.bp_name_string), "Didn't remove the name from the breakpoint.")

View File

@ -37,8 +37,8 @@ class DebugBreakTestCase(TestBase):
# We should be in funciton 'bar'.
self.assertTrue(frame.IsValid())
function_name = frame.GetFunctionName()
self.assertTrue('bar' in function_name,
"Unexpected function name {}".format(function_name))
self.assertIn('bar', function_name,
"Unexpected function name {}".format(function_name))
# We should be able to evaluate the parameter foo.
value = frame.EvaluateExpression('*foo')

View File

@ -23,7 +23,7 @@ class TestDataFormatterLibcxxQueue(TestBase):
self.assertTrue(var.IsValid())
queue = self.namespace + '::queue'
self.assertTrue(queue in var.GetDisplayTypeName())
self.assertIn(queue, var.GetDisplayTypeName())
self.assertEqual(var.GetNumChildren(), 5)
for i in range(5):
ch = var.GetChildAtIndex(i)

View File

@ -96,7 +96,7 @@ class TestGDBRemoteClient(GDBRemoteTestBase):
process = self.connect(target)
self.read_registers(process)
self.assertFalse("g" in self.server.responder.packetLog)
self.assertNotIn("g", self.server.responder.packetLog)
self.assertGreater(
len([p for p in self.server.responder.packetLog if p.startswith("p")]), 0)

View File

@ -30,8 +30,8 @@ class TestHistoryRecall(TestBase):
interp.HandleCommand("!0", result, False)
self.assertTrue(result.Succeeded(), "!0 command did not work: %s"%(result.GetError()))
self.assertTrue("session history" in result.GetOutput(), "!0 didn't rerun session history")
self.assertIn("session history", result.GetOutput(), "!0 didn't rerun session history")
interp.HandleCommand("!-1", result, False)
self.assertTrue(result.Succeeded(), "!-1 command did not work: %s"%(result.GetError()))
self.assertTrue("host:" in result.GetOutput(), "!-1 didn't rerun platform list.")
self.assertIn("host:", result.GetOutput(), "!-1 didn't rerun platform list.")

View File

@ -113,6 +113,6 @@ class TestOSPluginStepping(TestBase):
self.process.Continue()
os_thread = self.get_os_thread()
self.assertTrue(os_thread.IsValid(), "The OS thread is back after continue")
self.assertTrue("step out" in os_thread.GetStopDescription(100), "Completed step out plan")
self.assertIn("step out", os_thread.GetStopDescription(100), "Completed step out plan")

View File

@ -110,7 +110,7 @@ class MiniDumpNewTestCase(TestBase):
ci.HandleCommand(command, result, False)
message = 'Ensure memory "%s" shows up in output for "%s"' % (
region_name, command)
self.assertTrue(region_name in result.GetOutput(), message)
self.assertIn(region_name, result.GetOutput(), message)
def test_thread_info_in_minidump(self):
"""Test that lldb can read the thread information from the Minidump."""
@ -122,7 +122,7 @@ class MiniDumpNewTestCase(TestBase):
thread = self.process.GetThreadAtIndex(0)
self.assertEqual(thread.GetStopReason(), lldb.eStopReasonSignal)
stop_description = thread.GetStopDescription(256)
self.assertTrue("SIGSEGV" in stop_description)
self.assertIn("SIGSEGV", stop_description)
def test_stack_info_in_minidump(self):
"""Test that we can see a trivial stack in a breakpad-generated Minidump."""
@ -333,7 +333,7 @@ class MiniDumpNewTestCase(TestBase):
frame = thread.GetFrameAtIndex(index)
self.assertTrue(frame.IsValid())
function_name = frame.GetFunctionName()
self.assertTrue(name in function_name)
self.assertIn(name, function_name)
@skipIfLLVMTargetMissing("X86")
def test_deeper_stack_in_minidump(self):

View File

@ -38,7 +38,7 @@ class MiniDumpTestCase(TestBase):
thread = self.process.GetThreadAtIndex(0)
self.assertEqual(thread.GetStopReason(), lldb.eStopReasonException)
stop_description = thread.GetStopDescription(256)
self.assertTrue("0xc0000005" in stop_description)
self.assertIn("0xc0000005", stop_description)
def test_modules_in_mini_dump(self):
"""Test that lldb can read the list of modules from the minidump."""
@ -136,7 +136,7 @@ class MiniDumpTestCase(TestBase):
frame = thread.GetFrameAtIndex(index)
self.assertTrue(frame.IsValid())
function_name = frame.GetFunctionName()
self.assertTrue(name in function_name)
self.assertIn(name, function_name)
finally:
# Clean up the mini dump file.

View File

@ -56,7 +56,7 @@ class ProcessSaveCoreTestCase(TestBase):
os.path.join(
f.GetDirectory(),
f.GetFilename()) for f in files]
self.assertTrue(exe in paths)
self.assertIn(exe, paths)
finally:
# Clean up the mini dump file.

View File

@ -24,7 +24,7 @@ class TestTargetSourceMap(TestBase):
self.dbg.GetCommandInterpreter().HandleCommand("source list -f main.c -l 2", retval)
self.assertTrue(retval.Succeeded(), "source list didn't succeed.")
self.assertNotEqual(retval.GetOutput(), None, "We got no ouput from source list")
self.assertTrue("return" in retval.GetOutput(), "We didn't find the source file...")
self.assertIn("return", retval.GetOutput(), "We didn't find the source file...")
# Set the target soure map to map "./" to the current test directory
src_dir = self.getSourceDir()

View File

@ -28,7 +28,7 @@ class TestStatsAPI(TestBase):
res = stats.GetAsJSON(stream)
stats_json = sorted(json.loads(stream.GetData()))
self.assertEqual(len(stats_json), 4)
self.assertTrue("Number of expr evaluation failures" in stats_json)
self.assertTrue("Number of expr evaluation successes" in stats_json)
self.assertTrue("Number of frame var failures" in stats_json)
self.assertTrue("Number of frame var successes" in stats_json)
self.assertIn("Number of expr evaluation failures", stats_json)
self.assertIn("Number of expr evaluation successes", stats_json)
self.assertIn("Number of frame var failures", stats_json)
self.assertIn("Number of frame var successes", stats_json)

View File

@ -59,7 +59,7 @@ class StepScriptedTestCase(TestBase):
# Make sure we got a good error:
self.assertTrue(err.Fail(), "We got a failure state")
msg = err.GetCString()
self.assertTrue("NoSuchModule.NoSuchPlan" in msg, "Mentioned missing class")
self.assertIn("NoSuchModule.NoSuchPlan", msg, "Mentioned missing class")
# Make sure we didn't let the process run:
self.assertEqual(stop_id, process.GetStopID(), "Process didn't run")

View File

@ -61,5 +61,5 @@ class TestCrossDSOTailCalls(TestBase):
]
for idx, (name, is_artificial) in enumerate(expected_frames):
frame = thread.GetFrameAtIndex(idx)
self.assertTrue(name in frame.GetDisplayFunctionName())
self.assertIn(name, frame.GetDisplayFunctionName())
self.assertEqual(frame.IsArtificial(), is_artificial)

View File

@ -56,5 +56,5 @@ class TestCrossObjectTailCalls(TestBase):
]
for idx, (name, is_artificial) in enumerate(expected_frames):
frame = thread.GetFrameAtIndex(idx)
self.assertTrue(name in frame.GetDisplayFunctionName())
self.assertIn(name, frame.GetDisplayFunctionName())
self.assertEqual(frame.IsArtificial(), is_artificial)

View File

@ -61,5 +61,5 @@ class TestTailCallFrameSBAPI(TestBase):
# platform-dependent. E.g we see "void sink(void)" on Windows, but
# "sink()" on Darwin. This seems like a bug -- just work around it
# for now.
self.assertTrue(name in frame.GetDisplayFunctionName())
self.assertIn(name, frame.GetDisplayFunctionName())
self.assertEqual(frame.IsArtificial(), is_artificial)

View File

@ -63,7 +63,7 @@ class TsanBasicTestCase(TestBase):
process = self.dbg.GetSelectedTarget().process
thread = process.GetSelectedThread()
frame = thread.GetSelectedFrame()
self.assertTrue("__tsan_on_report" in frame.GetFunctionName())
self.assertIn("__tsan_on_report", frame.GetFunctionName())
# The stopped thread backtrace should contain either line1 or line2
# from main.c.

View File

@ -51,7 +51,7 @@ class UbsanBasicTestCase(TestBase):
substrs=['1 match found'])
# We should be stopped in __ubsan_on_report
self.assertTrue("__ubsan_on_report" in frame.GetFunctionName())
self.assertIn("__ubsan_on_report", frame.GetFunctionName())
# The stopped thread backtrace should contain either 'align line'
found = False

View File

@ -24,7 +24,7 @@ class TestVLA(TestBase):
var_opts.SetUseDynamic(lldb.eDynamicCanRunTarget)
all_locals = self.frame().GetVariables(var_opts)
for value in all_locals:
self.assertFalse("vla_expr" in value.name)
self.assertNotIn("vla_expr", value.name)
@decorators.skipIf(compiler="clang", compiler_version=['<', '8.0'])
def test_vla(self):

View File

@ -29,7 +29,7 @@ class CPPAcceleratorTableTestCase(TestBase):
n = 0
for line in log:
if re.findall(r'[abcdefg]\.o: FindByNameAndTag\(\)', line):
self.assertTrue("d.o" in line)
self.assertIn("d.o", line)
n += 1
self.assertEqual(n, 1, log)

View File

@ -138,7 +138,7 @@ class StaticVariableTestCase(TestBase):
for val in valList:
self.DebugSBValue(val)
name = val.GetName()
self.assertTrue(name in ['g_points', 'A::g_points'])
self.assertIn(name, ['g_points', 'A::g_points'])
if name == 'g_points':
self.assertEqual(
val.GetValueType(), lldb.eValueTypeVariableStatic)

View File

@ -220,5 +220,5 @@ class ClassTypesTestCase(TestBase):
frame = thread.frames[0]
self.assertTrue(frame.IsValid(), "Got a valid frame.")
self.assertTrue("C::C" in frame.name,
"Constructor name includes class name.")
self.assertIn("C::C", frame.name,
"Constructor name includes class name.")

View File

@ -36,7 +36,7 @@ class TestObjCDirectDispatchStepping(TestBase):
for idx in range(2,16):
thread.StepInto()
func_name = thread.GetFrameAtIndex(0).GetFunctionName()
self.assertTrue("OverridesALot" in func_name, "%d'th step did not match name: %s"%(idx, func_name))
self.assertIn("OverridesALot", func_name, "%d'th step did not match name: %s"%(idx, func_name))
stop_threads = lldbutil.continue_to_breakpoint(process, stop_bkpt)
self.assertEqual(len(stop_threads), 1)
self.assertEqual(stop_threads[0], thread)

View File

@ -123,7 +123,7 @@ class ObjCExceptionsTestCase(TestBase):
pcs = [i.unsigned for i in children]
names = [target.ResolveSymbolContextForAddress(lldb.SBAddress(pc, target), lldb.eSymbolContextSymbol).GetSymbol().name for pc in pcs]
for n in ["objc_exception_throw", "foo(int)", "main"]:
self.assertTrue(n in names, "%s is in the exception backtrace (%s)" % (n, names))
self.assertIn(n, names, "%s is in the exception backtrace (%s)" % (n, names))
def test_objc_exceptions_at_abort(self):
self.build()

View File

@ -73,7 +73,7 @@ class ObjCCheckerTestCase(TestBase):
# Make sure the error is helpful:
err_string = expr_error.GetCString()
self.assertTrue("selector" in err_string)
self.assertIn("selector", err_string)
#
# Check that we correctly insert the checker for an

View File

@ -31,7 +31,7 @@ class TestMacCatalyst(TestBase):
def check_debugserver(self, log):
"""scan the debugserver packet log"""
process_info = lldbutil.packetlog_get_process_info(log)
self.assertTrue('ostype' in process_info)
self.assertIn('ostype', process_info)
self.assertEquals(process_info['ostype'], 'maccatalyst')
aout_info = None

View File

@ -34,7 +34,7 @@ class TestMacCatalystAppWithMacOSFramework(TestBase):
def check_debugserver(self, log):
"""scan the debugserver packet log"""
process_info = lldbutil.packetlog_get_process_info(log)
self.assertTrue('ostype' in process_info)
self.assertIn('ostype', process_info)
self.assertEquals(process_info['ostype'], 'maccatalyst')
aout_info = None

View File

@ -29,7 +29,7 @@ class TestSimulatorPlatformLaunching(TestBase):
def check_debugserver(self, log, expected_platform, expected_version):
"""scan the debugserver packet log"""
process_info = lldbutil.packetlog_get_process_info(log)
self.assertTrue('ostype' in process_info)
self.assertIn('ostype', process_info)
self.assertEquals(process_info['ostype'], expected_platform)
dylib_info = lldbutil.packetlog_get_dylib_info(log)
self.assertTrue(dylib_info)

View File

@ -35,7 +35,7 @@ class TestGdbRemoteAuxvSupport(gdbremote_testcase.GdbRemoteTestCaseBase):
proc_info = self.parse_process_info_response(context)
self.assertIsNotNone(proc_info)
self.assertTrue("ptrsize" in proc_info)
self.assertIn("ptrsize", proc_info)
word_size = int(proc_info["ptrsize"])
OFFSET = 0

View File

@ -54,7 +54,7 @@ class TestGdbRemoteExpeditedRegisters(
self.assertIsNotNone(reg_info)
# Ensure the expedited registers contained it.
self.assertTrue(reg_info["lldb_register_index"] in expedited_registers)
self.assertIn(reg_info["lldb_register_index"], expedited_registers)
self.trace("{} reg_info:{}".format(generic_register_name, reg_info))
def test_stop_notification_contains_any_registers(self):
@ -121,5 +121,5 @@ class TestGdbRemoteExpeditedRegisters(
self.assertIsNotNone(reg_info)
# Ensure the expedited registers contained it.
self.assertTrue(reg_info["lldb_register_index"] in expedited_registers)
self.assertIn(reg_info["lldb_register_index"], expedited_registers)
self.trace("{} reg_info:{}".format('vg', reg_info))

View File

@ -66,8 +66,8 @@ class TestGdbRemoteHostInfo(GdbRemoteTestCaseBase):
# Validate keys are known.
for (key, val) in list(host_info_dict.items()):
self.assertTrue(key in self.KNOWN_HOST_INFO_KEYS,
"unknown qHostInfo key: " + key)
self.assertIn(key, self.KNOWN_HOST_INFO_KEYS,
"unknown qHostInfo key: " + key)
self.assertIsNotNone(val)
# Return the key:val pairs.

View File

@ -22,7 +22,7 @@ class TestGdbRemote_vCont(gdbremote_testcase.GdbRemoteTestCaseBase):
self.assertIsNotNone(supported_vCont_modes)
# Verify we support the given mode.
self.assertTrue(mode in supported_vCont_modes)
self.assertIn(mode, supported_vCont_modes)
def test_vCont_supports_c(self):

View File

@ -158,17 +158,17 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod
reg_info['generic']: 1 for reg_info in reg_infos if 'generic' in reg_info}
# Ensure we have a program counter register.
self.assertTrue('pc' in generic_regs)
self.assertIn('pc', generic_regs)
# Ensure we have a frame pointer register. PPC64le's FP is the same as SP
if self.getArchitecture() != 'powerpc64le':
self.assertTrue('fp' in generic_regs)
self.assertIn('fp', generic_regs)
# Ensure we have a stack pointer register.
self.assertTrue('sp' in generic_regs)
self.assertIn('sp', generic_regs)
# Ensure we have a flags register.
self.assertTrue('flags' in generic_regs)
self.assertIn('flags', generic_regs)
def test_qRegisterInfo_contains_at_least_one_register_set(self):
self.build()
@ -442,7 +442,7 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod
# Ensure we haven't seen this tid yet.
thread_id = int(context.get("thread_id"), 16)
self.assertFalse(thread_id in signaled_tids)
self.assertNotIn(thread_id, signaled_tids)
signaled_tids[thread_id] = 1
# Send SIGUSR1 to the thread that signaled the SIGSEGV.
@ -490,7 +490,7 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod
print_thread_id = context.get("print_thread_id")
self.assertIsNotNone(print_thread_id)
print_thread_id = int(print_thread_id, 16)
self.assertFalse(print_thread_id in print_thread_ids)
self.assertNotIn(print_thread_id, print_thread_ids)
# Now remember this print (i.e. inferior-reflected) thread id and
# ensure we don't hit it again.
@ -629,12 +629,12 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod
mem_region_dict = self.parse_memory_region_packet(context)
# Ensure there are no errors reported.
self.assertFalse("error" in mem_region_dict)
self.assertNotIn("error", mem_region_dict)
# Ensure code address is readable and executable.
self.assertTrue("permissions" in mem_region_dict)
self.assertTrue("r" in mem_region_dict["permissions"])
self.assertTrue("x" in mem_region_dict["permissions"])
self.assertIn("permissions", mem_region_dict)
self.assertIn("r", mem_region_dict["permissions"])
self.assertIn("x", mem_region_dict["permissions"])
# Ensure the start address and size encompass the address we queried.
self.assert_address_within_memory_region(code_address, mem_region_dict)
@ -681,12 +681,12 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod
mem_region_dict = self.parse_memory_region_packet(context)
# Ensure there are no errors reported.
self.assertFalse("error" in mem_region_dict)
self.assertNotIn("error", mem_region_dict)
# Ensure address is readable and executable.
self.assertTrue("permissions" in mem_region_dict)
self.assertTrue("r" in mem_region_dict["permissions"])
self.assertTrue("w" in mem_region_dict["permissions"])
self.assertIn("permissions", mem_region_dict)
self.assertIn("r", mem_region_dict["permissions"])
self.assertIn("w", mem_region_dict["permissions"])
# Ensure the start address and size encompass the address we queried.
self.assert_address_within_memory_region(
@ -734,12 +734,12 @@ class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcod
mem_region_dict = self.parse_memory_region_packet(context)
# Ensure there are no errors reported.
self.assertFalse("error" in mem_region_dict)
self.assertNotIn("error", mem_region_dict)
# Ensure address is readable and executable.
self.assertTrue("permissions" in mem_region_dict)
self.assertTrue("r" in mem_region_dict["permissions"])
self.assertTrue("w" in mem_region_dict["permissions"])
self.assertIn("permissions", mem_region_dict)
self.assertIn("r", mem_region_dict["permissions"])
self.assertIn("w", mem_region_dict["permissions"])
# Ensure the start address and size encompass the address we queried.
self.assert_address_within_memory_region(heap_address, mem_region_dict)

View File

@ -127,7 +127,7 @@ class TestVSCode_setBreakpoints(lldbvscode_testcase.VSCodeTestCaseBase):
self.assertTrue(line, lines[index])
# Store the "id" of the breakpoint that was set for later
line_to_id[line] = breakpoint['id']
self.assertTrue(line in lines, "line expected in lines array")
self.assertIn(line, lines, "line expected in lines array")
self.assertTrue(breakpoint['verified'],
"expect breakpoint verified")
@ -153,7 +153,7 @@ class TestVSCode_setBreakpoints(lldbvscode_testcase.VSCodeTestCaseBase):
# making sure the breakpoint ID didn't change
self.assertEquals(line_to_id[line], breakpoint['id'],
"verify previous breakpoints stayed the same")
self.assertTrue(line in lines, "line expected in lines array")
self.assertIn(line, lines, "line expected in lines array")
self.assertTrue(breakpoint['verified'],
"expect breakpoint still verified")
@ -172,7 +172,7 @@ class TestVSCode_setBreakpoints(lldbvscode_testcase.VSCodeTestCaseBase):
# making sure the breakpoint ID didn't change
self.assertEquals(line_to_id[line], breakpoint['id'],
"verify previous breakpoints stayed the same")
self.assertTrue(line in lines, "line expected in lines array")
self.assertIn(line, lines, "line expected in lines array")
self.assertTrue(breakpoint['verified'],
"expect breakpoint still verified")
@ -202,7 +202,7 @@ class TestVSCode_setBreakpoints(lldbvscode_testcase.VSCodeTestCaseBase):
"expect %u source breakpoints" % (len(lines)))
for breakpoint in breakpoints:
line = breakpoint['line']
self.assertTrue(line in lines, "line expected in lines array")
self.assertIn(line, lines, "line expected in lines array")
self.assertTrue(breakpoint['verified'],
"expect breakpoint still verified")
@ -217,7 +217,7 @@ class TestVSCode_setBreakpoints(lldbvscode_testcase.VSCodeTestCaseBase):
"expect %u source breakpoints" % (len(lines)))
for breakpoint in breakpoints:
line = breakpoint['line']
self.assertTrue(line in lines, "line expected in lines array")
self.assertIn(line, lines, "line expected in lines array")
self.assertTrue(breakpoint['verified'],
"expect breakpoint still verified")
@ -248,7 +248,7 @@ class TestVSCode_setBreakpoints(lldbvscode_testcase.VSCodeTestCaseBase):
self.assertTrue(line, lines[index])
# Store the "id" of the breakpoint that was set for later
line_to_id[line] = breakpoint['id']
self.assertTrue(line in lines, "line expected in lines array")
self.assertIn(line, lines, "line expected in lines array")
self.assertTrue(breakpoint['verified'],
"expect breakpoint verified")

View File

@ -19,10 +19,10 @@ class TestVSCode_console(lldbvscode_testcase.VSCodeTestCaseBase):
def check_lldb_command(self, lldb_command, contains_string, assert_msg):
response = self.vscode.request_evaluate('`%s' % (lldb_command))
output = response['body']['result']
self.assertTrue(contains_string in output,
("""Verify %s by checking the command output:\n"""
"""'''\n%s'''\nfor the string: "%s" """ % (
assert_msg, output, contains_string)))
self.assertIn(contains_string, output,
("""Verify %s by checking the command output:\n"""
"""'''\n%s'''\nfor the string: "%s" """ % (
assert_msg, output, contains_string)))
@skipIfWindows
@skipIfRemote

View File

@ -33,8 +33,8 @@ class TestVSCode_launch(lldbvscode_testcase.VSCodeTestCaseBase):
self.assertTrue(output and len(output) > 0,
"expect program output")
lines = output.splitlines()
self.assertTrue(program in lines[0],
"make sure program path is in first argument")
self.assertIn(program, lines[0],
"make sure program path is in first argument")
@skipIfWindows
@skipIfRemote
@ -104,9 +104,9 @@ class TestVSCode_launch(lldbvscode_testcase.VSCodeTestCaseBase):
if line.startswith('cwd = \"'):
quote_path = '"%s"' % (program_parent_dir)
found = True
self.assertTrue(quote_path in line,
"working directory '%s' not in '%s'" % (
program_parent_dir, line))
self.assertIn(quote_path, line,
"working directory '%s' not in '%s'" % (
program_parent_dir, line))
self.assertTrue(found, "verified program working directory")
@skipIfWindows
@ -202,9 +202,9 @@ class TestVSCode_launch(lldbvscode_testcase.VSCodeTestCaseBase):
for line in lines:
quote_path = '"%s"' % (program)
if line.startswith("arg[1] ="):
self.assertTrue(quote_path in line,
'verify "%s" expanded to "%s"' % (
glob, program))
self.assertIn(quote_path, line,
'verify "%s" expanded to "%s"' % (
glob, program))
@skipIfWindows
@skipIfRemote
@ -228,9 +228,9 @@ class TestVSCode_launch(lldbvscode_testcase.VSCodeTestCaseBase):
for line in lines:
quote_path = '"%s"' % (glob)
if line.startswith("arg[1] ="):
self.assertTrue(quote_path in line,
'verify "%s" stayed to "%s"' % (
glob, glob))
self.assertIn(quote_path, line,
'verify "%s" stayed to "%s"' % (
glob, glob))
@skipIfWindows
@skipIfRemote
@ -255,8 +255,8 @@ class TestVSCode_launch(lldbvscode_testcase.VSCodeTestCaseBase):
# Make sure arguments we specified are correct
for (i, arg) in enumerate(args):
quoted_arg = '"%s"' % (arg)
self.assertTrue(quoted_arg in lines[i],
'arg[%i] "%s" not in "%s"' % (i+1, quoted_arg, lines[i]))
self.assertIn(quoted_arg, lines[i],
'arg[%i] "%s" not in "%s"' % (i+1, quoted_arg, lines[i]))
@skipIfWindows
@skipIfRemote

View File

@ -31,7 +31,7 @@ class TestVSCode_module(lldbvscode_testcase.VSCodeTestCaseBase):
self.assertEqual(program_basename, program_module['name'])
self.assertIn('path', program_module, 'make sure path is in module')
self.assertEqual(program, program_module['path'])
self.assertTrue('symbolFilePath' not in program_module, 'Make sure a.out.stripped has no debug info')
self.assertNotIn('symbolFilePath', program_module, 'Make sure a.out.stripped has no debug info')
symbols_path = self.getBuildArtifact(symbol_basename)
self.vscode.request_evaluate('`%s' % ('target symbols add -s "%s" "%s"' % (program, symbols_path)))

View File

@ -69,8 +69,8 @@ class TestVSCode_variables(lldbvscode_testcase.VSCodeTestCaseBase):
def verify_variables(self, verify_dict, variables, varref_dict=None):
for variable in variables:
name = variable['name']
self.assertTrue(name in verify_dict,
'variable "%s" in verify dictionary' % (name))
self.assertIn(name, verify_dict,
'variable "%s" in verify dictionary' % (name))
self.verify_values(verify_dict[name], variable, varref_dict)
@skipIfWindows