xref: /llvm-project/lldb/test/API/test_utils/TestPExpectTest.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1"""
2Test the PExpectTest test functions.
3"""
4
5from lldbsuite.test.lldbpexpect import *
6
7
8class TestPExpectTestCase(PExpectTest):
9    NO_DEBUG_INFO_TESTCASE = True
10
11    def assert_expect_fails_with(self, cmd, expect_args, expected_msg):
12        try:
13            self.expect(cmd, **expect_args)
14        except AssertionError as e:
15            self.assertIn(expected_msg, str(e))
16        else:
17            self.fail("expect should have raised AssertionError!")
18
19    def test_expect(self):
20        # Test that passing a string to the 'substrs' argument is rejected.
21        self.assert_expect_fails_with(
22            "settings list prompt",
23            dict(substrs="some substring"),
24            "substrs must be a collection of strings",
25        )
26