From b9684879e70bed0f3dd9ecbdc331ee8efed89e43 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 21 Feb 2022 14:24:08 +0530 Subject: [PATCH] Try to fix tests failing on CI --- kitty_tests/__init__.py | 8 +++++++- kitty_tests/ssh.py | 7 +++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/kitty_tests/__init__.py b/kitty_tests/__init__.py index c85b8023d..720e616c9 100644 --- a/kitty_tests/__init__.py +++ b/kitty_tests/__init__.py @@ -129,6 +129,12 @@ class BaseTest(TestCase): set_options(options) return options + def cmd_to_run_python_code(self, code): + cmd = [sys.executable] + cmd.append('-c' if 'python' in sys.executable.lower() else '+runpy') + cmd.append(code) + return cmd + def create_screen(self, cols=5, lines=5, scrollback=5, cell_width=10, cell_height=20, options=None): self.set_options(options) c = Callbacks() @@ -178,7 +184,7 @@ class PTY: def write_to_child(self, data): write_all(self.master_fd, data) - def wait_for_input_from_child(self, timeout=2): + def wait_for_input_from_child(self, timeout=10): rd = select.select([self.master_fd], [], [], timeout)[0] return bool(rd) diff --git a/kitty_tests/ssh.py b/kitty_tests/ssh.py index 04a49f460..c5730116a 100644 --- a/kitty_tests/ssh.py +++ b/kitty_tests/ssh.py @@ -3,7 +3,6 @@ import os -import sys from kittens.ssh.main import get_connection_data from kitty.utils import SSHConnectionData @@ -18,14 +17,14 @@ class SSHTest(BaseTest): self.assertTrue(pty.wait_for_input_from_child()) pty.process_input_from_child() self.ae(pty.screen_contents(), 'hello') - pty = self.create_pty([sys.executable, '-c', '''\ + pty = self.create_pty(self.cmd_to_run_python_code('''\ import array, fcntl, sys, termios buf = array.array('H', [0, 0, 0, 0]) fcntl.ioctl(sys.stdout, termios.TIOCGWINSZ, buf) -print(' '.join(map(str, buf)))'''], lines=13, cols=17) +print(' '.join(map(str, buf)))'''), lines=13, cols=77) self.assertTrue(pty.wait_for_input_from_child()) pty.process_input_from_child() - self.ae(pty.screen_contents(), '13 17 0 0') + self.ae(pty.screen_contents(), '13 77 0 0') def test_ssh_connection_data(self): def t(cmdline, binary='ssh', host='main', port=None, identity_file=''):