Files
clang-p2996/lldb/test/API/python_api/format/TestFormat.py
Jordan Rupprecht 9c2468821e [lldb][test] Modernize asserts (#82503)
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`.
2024-02-21 13:02:30 -06:00

25 lines
721 B
Python

"""
Test the lldb Python SBFormat API.
"""
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
class FormatAPITestCase(TestBase):
def test_format(self):
format = lldb.SBFormat()
self.assertFalse(format)
error = lldb.SBError()
format = lldb.SBFormat("${bad}", error)
self.assertIn("invalid top level item 'bad'", error.GetCString())
self.assertFalse(format) # We expect an invalid object back if we have an error
self.assertTrue(error.Fail())
format = lldb.SBFormat("${frame.index}", error)
self.assertIsNone(error.GetCString())
self.assertTrue(format)
self.assertTrue(error.Success())