From bbd2df7e4d93c4fd1b3978b73431414f4e24d7f6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 29 Oct 2024 06:01:35 +0530 Subject: [PATCH] Nicer error message on I/O error with child over pty --- kitty_tests/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kitty_tests/__init__.py b/kitty_tests/__init__.py index 810d54ef9..103c231b1 100644 --- a/kitty_tests/__init__.py +++ b/kitty_tests/__init__.py @@ -391,7 +391,12 @@ class PTY: def wait_till(self, q, timeout=10, timeout_msg=None): end_time = time.monotonic() + timeout while not q() and time.monotonic() <= end_time: - self.process_input_from_child(timeout=end_time - time.monotonic()) + try: + self.process_input_from_child(timeout=end_time - time.monotonic()) + except OSError as e: + if not q(): + raise Exception(f'Failed to read from pty with error: {e}. Screen contents: \n {repr(self.screen_contents())}') from e + return if not q(): msg = 'The condition was not met' if timeout_msg is not None: