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`.
25 lines
721 B
Python
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())
|