aboutsummaryrefslogtreecommitdiff
path: root/lldb/test/API/python_api/value
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2022-06-08 15:57:41 -0700
committerJonas Devlieghere <jonas@devlieghere.com>2022-06-08 16:16:38 -0700
commitce825e46743be3e402820484bef639d12deefc2a (patch)
tree0896b46e420b5ff9ea2d68337da79366e9a82b14 /lldb/test/API/python_api/value
parent5ead1f13a2d8ca33e9e93c06acee941a857905c6 (diff)
downloadllvm-ce825e46743be3e402820484bef639d12deefc2a.zip
llvm-ce825e46743be3e402820484bef639d12deefc2a.tar.gz
llvm-ce825e46743be3e402820484bef639d12deefc2a.tar.bz2
[lldb] Add assertState function to the API test suite
Add a function to make it easier to debug a test failure caused by an unexpected state. Currently, tests are using assertEqual which results in a cryptic error message: "AssertionError: 5 != 10". Even when a test provides a message to make it clear why a particular state is expected, you still have to figure out which of the two was the expected state, and what the other value corresponds to. We have a function in lldbutil that helps you convert the state number into a user readable string. This patch adds a wrapper around assertEqual specifically for comparing states and reporting better error messages. The aforementioned error message now looks like this: "AssertionError: stopped (5) != exited (10)". If the user provided a message, that continues to get printed as well. Differential revision: https://reviews.llvm.org/D127355
Diffstat (limited to 'lldb/test/API/python_api/value')
-rw-r--r--lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py6
-rw-r--r--lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py2
2 files changed, 4 insertions, 4 deletions
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 d8b490b..3e2d3c6 100644
--- a/lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py
+++ b/lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py
@@ -59,7 +59,7 @@ class ChangeValueAPITestCase(TestBase):
self.assertTrue(process, PROCESS_IS_VALID)
# Get Frame #0.
- self.assertEquals(process.GetState(), lldb.eStateStopped)
+ self.assertState(process.GetState(), lldb.eStateStopped)
thread = lldbutil.get_stopped_thread(
process, lldb.eStopReasonBreakpoint)
self.assertTrue(
@@ -136,7 +136,7 @@ class ChangeValueAPITestCase(TestBase):
# Now continue.
process.Continue()
- self.assertEquals(process.GetState(), lldb.eStateStopped)
+ self.assertState(process.GetState(), lldb.eStateStopped)
thread = lldbutil.get_stopped_thread(
process, lldb.eStopReasonBreakpoint)
self.assertTrue(
@@ -169,7 +169,7 @@ class ChangeValueAPITestCase(TestBase):
process.Continue()
- self.assertEquals(process.GetState(), lldb.eStateStopped)
+ self.assertState(process.GetState(), lldb.eStateStopped)
thread = lldbutil.get_stopped_thread(
process, lldb.eStopReasonBreakpoint)
self.assertTrue(
diff --git a/lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py b/lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py
index ac8f60b..f4a3f5a 100644
--- a/lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py
+++ b/lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py
@@ -27,7 +27,7 @@ class ValueAPIEmptyClassTestCase(TestBase):
self.assertTrue(process, PROCESS_IS_VALID)
# Get Frame #0.
- self.assertEquals(process.GetState(), lldb.eStateStopped)
+ self.assertState(process.GetState(), lldb.eStateStopped)
thread = lldbutil.get_stopped_thread(
process, lldb.eStopReasonBreakpoint)
self.assertTrue(