xref: /llvm-project/lldb/test/API/test_utils/TestPExpectTest.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
12f84b59aSRaphael Isemann"""
22f84b59aSRaphael IsemannTest the PExpectTest test functions.
32f84b59aSRaphael Isemann"""
42f84b59aSRaphael Isemann
50c118831SRaphael Isemannfrom lldbsuite.test.lldbpexpect import *
62f84b59aSRaphael Isemann
7*2238dcc3SJonas Devlieghere
80c118831SRaphael Isemannclass TestPExpectTestCase(PExpectTest):
92f84b59aSRaphael Isemann    NO_DEBUG_INFO_TESTCASE = True
102f84b59aSRaphael Isemann
112f84b59aSRaphael Isemann    def assert_expect_fails_with(self, cmd, expect_args, expected_msg):
122f84b59aSRaphael Isemann        try:
132f84b59aSRaphael Isemann            self.expect(cmd, **expect_args)
142f84b59aSRaphael Isemann        except AssertionError as e:
152f84b59aSRaphael Isemann            self.assertIn(expected_msg, str(e))
162f84b59aSRaphael Isemann        else:
172f84b59aSRaphael Isemann            self.fail("expect should have raised AssertionError!")
182f84b59aSRaphael Isemann
192f84b59aSRaphael Isemann    def test_expect(self):
202f84b59aSRaphael Isemann        # Test that passing a string to the 'substrs' argument is rejected.
21*2238dcc3SJonas Devlieghere        self.assert_expect_fails_with(
22*2238dcc3SJonas Devlieghere            "settings list prompt",
232f84b59aSRaphael Isemann            dict(substrs="some substring"),
24*2238dcc3SJonas Devlieghere            "substrs must be a collection of strings",
25*2238dcc3SJonas Devlieghere        )
26