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/python_api/interpreter/TestRunCommandInterpreterAPI.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/python_api/interpreter/TestRunCommandInterpreterAPI.py')
| -rw-r--r-- | lldb/test/API/python_api/interpreter/TestRunCommandInterpreterAPI.py | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/lldb/test/API/python_api/interpreter/TestRunCommandInterpreterAPI.py b/lldb/test/API/python_api/interpreter/TestRunCommandInterpreterAPI.py index 64e0770dc0b1..af9749313376 100644 --- a/lldb/test/API/python_api/interpreter/TestRunCommandInterpreterAPI.py +++ b/lldb/test/API/python_api/interpreter/TestRunCommandInterpreterAPI.py @@ -79,13 +79,13 @@ class SBCommandInterpreterRunOptionsCase(TestBase): opts = lldb.SBCommandInterpreterRunOptions() # Check getters with default values - self.assertEqual(opts.GetStopOnContinue(), False) - self.assertEqual(opts.GetStopOnError(), False) - self.assertEqual(opts.GetStopOnCrash(), False) - self.assertEqual(opts.GetEchoCommands(), True) - self.assertEqual(opts.GetPrintResults(), True) - self.assertEqual(opts.GetPrintErrors(), True) - self.assertEqual(opts.GetAddToHistory(), True) + self.assertFalse(opts.GetStopOnContinue()) + self.assertFalse(opts.GetStopOnError()) + self.assertFalse(opts.GetStopOnCrash()) + self.assertTrue(opts.GetEchoCommands()) + self.assertTrue(opts.GetPrintResults()) + self.assertTrue(opts.GetPrintErrors()) + self.assertTrue(opts.GetAddToHistory()) # Invert values opts.SetStopOnContinue(not opts.GetStopOnContinue()) @@ -97,10 +97,10 @@ class SBCommandInterpreterRunOptionsCase(TestBase): opts.SetAddToHistory(not opts.GetAddToHistory()) # Check the value changed - self.assertEqual(opts.GetStopOnContinue(), True) - self.assertEqual(opts.GetStopOnError(), True) - self.assertEqual(opts.GetStopOnCrash(), True) - self.assertEqual(opts.GetEchoCommands(), False) - self.assertEqual(opts.GetPrintResults(), False) - self.assertEqual(opts.GetPrintErrors(), False) - self.assertEqual(opts.GetAddToHistory(), False) + self.assertTrue(opts.GetStopOnContinue()) + self.assertTrue(opts.GetStopOnError()) + self.assertTrue(opts.GetStopOnCrash()) + self.assertFalse(opts.GetEchoCommands()) + self.assertFalse(opts.GetPrintResults()) + self.assertFalse(opts.GetPrintErrors()) + self.assertFalse(opts.GetAddToHistory()) |
