diff options
| author | Jordan Rupprecht <rupprecht@google.com> | 2024-02-21 20:39:02 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-21 20:39:02 -0600 |
| commit | 1eeeab82c6eb185f5139e633a59c2dbcb15616e4 (patch) | |
| tree | 5d96fb3074f6deb818dd84b7ec7258d68d320c1f /lldb/test/API/functionalities/module_cache/simple_exe/TestModuleCacheSimple.py | |
| parent | 0d12628d06b8ab37157faea474548735ddb7eeb2 (diff) | |
[lldb][test] Modernize assertEqual(value, bool) (#82526)
Any time we see the pattern `assertEqual(value, bool)`, we can replace
that with `assert<bool>(value)`. Likewise for `assertNotEqual`.
Technically this relaxes the test a bit, as we may want to make sure
`value` is either `True` or `False`, and not something that implicitly
converts to a bool. For example, `assertEqual("foo", True)` will fail,
but `assertTrue("foo")` will not. In most cases, this distinction is not
important.
There are two such places that this patch does **not** transform, since
it seems intentional that we want the result to be a bool:
*
https://github.com/llvm/llvm-project/blob/5daf2001a1e4d71ce1273a1e7e31cf6e6ac37c10/lldb/test/API/python_api/sbstructureddata/TestStructuredDataAPI.py#L90
*
https://github.com/llvm/llvm-project/blob/5daf2001a1e4d71ce1273a1e7e31cf6e6ac37c10/lldb/test/API/commands/settings/TestSettings.py#L940
Followup to 9c2468821ec51defd09c246fea4a47886fff8c01. I patched `teyit`
with a `visit_assertEqual` node handler to generate this.
Diffstat (limited to 'lldb/test/API/functionalities/module_cache/simple_exe/TestModuleCacheSimple.py')
| -rw-r--r-- | lldb/test/API/functionalities/module_cache/simple_exe/TestModuleCacheSimple.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/lldb/test/API/functionalities/module_cache/simple_exe/TestModuleCacheSimple.py b/lldb/test/API/functionalities/module_cache/simple_exe/TestModuleCacheSimple.py index 4214bd108bfc..abf4cf3944e1 100644 --- a/lldb/test/API/functionalities/module_cache/simple_exe/TestModuleCacheSimple.py +++ b/lldb/test/API/functionalities/module_cache/simple_exe/TestModuleCacheSimple.py @@ -66,18 +66,16 @@ class ModuleCacheTestcaseSimple(TestBase): # get a different creation and modification time for the file since some # OSs store the modification time in seconds since Jan 1, 1970. os.remove(exe) - self.assertEqual( - os.path.exists(exe), - False, - "make sure we were able to remove the executable", + self.assertFalse( + os.path.exists(exe), "make sure we were able to remove the executable" ) time.sleep(2) # Now rebuild the binary so it has a different content which should # update the UUID to make the cache miss when it tries to load the # symbol table from the binary at the same path. self.build(dictionary={"CFLAGS_EXTRAS": "-DEXTRA_FUNCTION"}) - self.assertEqual( - os.path.exists(exe), True, "make sure executable exists after rebuild" + self.assertTrue( + os.path.exists(exe), "make sure executable exists after rebuild" ) # Make sure the modification time has changed or this test will fail. exe_mtime_2 = os.path.getmtime(exe) @@ -99,9 +97,8 @@ class ModuleCacheTestcaseSimple(TestBase): main_module = target.GetModuleAtIndex(0) self.assertTrue(main_module.IsValid()) main_module.GetNumSymbols() - self.assertEqual( + self.assertTrue( os.path.exists(symtab_cache_path), - True, 'make sure "symtab" cache files exists after cache is updated', ) symtab_mtime_2 = os.path.getmtime(symtab_cache_path) |
