From: Plom Heller Date: Fri, 6 Mar 2026 04:16:25 +0000 (+0100) Subject: To testing add "just_enter" prompt directive to handle pre-filled prompts. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%22https:/validator.w3.org/booking?a=commitdiff_plain;ds=inline;p=ircplom To testing add "just_enter" prompt directive to handle pre-filled prompts. --- diff --git a/src/ircplom/testing.py b/src/ircplom/testing.py index 92c8ea6..53b06c9 100644 --- a/src/ircplom/testing.py +++ b/src/ircplom/testing.py @@ -34,6 +34,8 @@ _TOK_FILE = './' _TOK_IDX_REPEAT = 'r' _KW_BUMP = 'bump=' _KW_RANGE = 'range=' +_PROMPT_RAISE_SIGWINCH = 'raise_sigwinch' +_PROMPT_JUST_ENTER = 'just_enter' _SIGNATURE_FOR_CMD = { _MARK_FRAGMENT: (1, None), @@ -448,15 +450,17 @@ class _Playbook: def _play_till_test(self) -> None: while True: if self._idx >= len(self._lines_t): - self._lines_t += [('', '> /quit'), - ('', 'log 0 <..')] + self._lines_t += [('', f'{_MARK_PROMPT} /quit'), + ('', f'{_MARK_LOG} 0 <..')] cmd_name, args = self._cmdname_and_args_from(self._current_line[1]) if cmd_name == _MARK_PROMPT: assert self.put_keypress is not None - if args[0] == 'raise_sigwinch': + if args[0] == _PROMPT_RAISE_SIGWINCH: args = ('',) self._lines_t[self._idx:self._idx + 1] = [('', '> ')] raise_signal(SIGWINCH) + elif args[0] == _PROMPT_JUST_ENTER: + args = ('',) for c in args[0]: self.put_keypress(c) self.put_keypress('KEY_ENTER') @@ -554,5 +558,6 @@ class TestingClientTui(ClientTui): def cmd__prompt_enter(self) -> None: def test_before(cmd_name: str, args: tuple[str, ...]) -> None: assert cmd_name == _MARK_PROMPT - assert args[0] == self.window.prompt.input_buffer[:] + if args[0] != _PROMPT_JUST_ENTER: + assert args[0] == self.window.prompt.input_buffer self._playbook.test_wrap(test_before, None, super().cmd__prompt_enter)