From 04af71696a59597eef62c4591081ae4813aaff48 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 5 May 2024 13:59:23 +0530 Subject: [PATCH] Make processing of input from child in test pty device a bit more robust --- kitty_tests/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kitty_tests/__init__.py b/kitty_tests/__init__.py index cbe56ae4b..74ba5e600 100644 --- a/kitty_tests/__init__.py +++ b/kitty_tests/__init__.py @@ -337,7 +337,7 @@ def send_cmd_to_child(self, cmd, flush=False): self.write_to_child(cmd + '\r', flush=flush) def process_input_from_child(self, timeout=10): - rd, wd, err = select.select([self.master_fd], [self.master_fd] if self.write_buf else [], [], timeout) + rd, wd, _ = select.select([self.master_fd], [self.master_fd] if self.write_buf else [], [], max(0, timeout)) while wd: try: n = os.write(self.master_fd, self.write_buf) @@ -363,7 +363,7 @@ def process_input_from_child(self, timeout=10): def wait_till(self, q, timeout=10): end_time = time.monotonic() + timeout while not q() and time.monotonic() <= end_time: - self.process_input_from_child(timeout=max(0, end_time - time.monotonic())) + self.process_input_from_child(timeout=end_time - time.monotonic()) if not q(): raise TimeoutError(f'The condition was not met. Screen contents: \n {repr(self.screen_contents())}')