From e9ccf5d31b8187a97ad7452f52221d95ffc687d2 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Wed, 15 Oct 2025 00:03:48 +0200 Subject: [PATCH] In testing, for TUI directives call .redraw_affected directly when needed. --- src/ircplom/testing.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ircplom/testing.py b/src/ircplom/testing.py index 58b39fa..b63a3ad 100644 --- a/src/ircplom/testing.py +++ b/src/ircplom/testing.py @@ -144,6 +144,7 @@ _TOK_TUI = 'TUI' class _Playbook: put_keypress: Optional[Callable] = None assert_screen_line: Optional[Callable] = None + redraw_affected: Optional[Callable] = None def __init__(self, path: Path, get_client: Callable, verbose: bool ) -> None: @@ -269,6 +270,8 @@ class _Playbook: client.conn.put_server_msg(msg) elif context == _TOK_TUI: assert self.assert_screen_line is not None + assert self.redraw_affected is not None + self.redraw_affected() position, attrs_str, msg = msg.split('.', maxsplit=2) y, x = ((int(item) for item in position.split(',')) if ',' in position @@ -307,6 +310,7 @@ class TestingClientTui(ClientTui): super().__init__(**kwargs) assert isinstance(self._term, TestTerminal) self._playbook.assert_screen_line = self._term.assert_screen_line + self._playbook.redraw_affected = self.redraw_affected self._playbook.put_keypress = self._term._q_keypresses.put self._playbook.ensure_has_started() # if .__init__ didn't yet by log() @@ -324,12 +328,6 @@ class TestingClientTui(ClientTui): def log(self, msg: str, **kwargs) -> tuple[tuple[int, ...], str]: win_ids, logged_msg = super().log(msg, **kwargs) - # usually whatever called log would call .redraw_affected directly - # after, but for TUI display tests on the effects of .log that might - # follow directly in the playbook (i.e. will run before .log actually - # finishes, signaling to caller they should call .redraw_affected) we - # want this available immediately - self.redraw_affected() fmt, time_str, msg_sans_time = logged_msg.split(' ', maxsplit=2) msg_sans_time = fmt + ' ' + msg_sans_time assert len(time_str) == 8 -- 2.30.2