From d6e1a8f224698fb88cdd196cf4f731f1d4ddd94a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kr=C3=B6ger?= Date: Mon, 11 Nov 2024 22:05:03 +0100 Subject: [PATCH] Make tests executable again. --- .github/tests.yml | 0 tests/__init__.py | 15 +++++++++++++++ tests/test_basic.py | 2 ++ tests/test_command_line.py | 2 +- tests/test_control_commands.py | 3 ++- tests/test_display_names.py | 3 ++- tests/test_host_syntax.py | 3 ++- tests/test_non_interactive.py | 3 ++- tests/test_password_file.py | 3 ++- 9 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 .github/tests.yml diff --git a/.github/tests.yml b/.github/tests.yml new file mode 100644 index 0000000..e69de29 diff --git a/tests/__init__.py b/tests/__init__.py index 255c7a4..207d4a2 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -3,6 +3,10 @@ Copyright (c) 2006 Guillaume Chazarain Copyright (c) 2024 InnoGames GmbH """ +import pexpect +from pexpect.popen_spawn import PopenSpawn + + # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or @@ -15,3 +19,14 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . + +def launch_polysh(args, input_data=None): + args = ['uv', 'run', 'polysh'] + args + + if input_data is None: + child = pexpect.spawn(args[0], args=args[1:], encoding='utf-8') + else: + child = PopenSpawn(args) + child.send(input_data) + child.sendeof() + return child \ No newline at end of file diff --git a/tests/test_basic.py b/tests/test_basic.py index 950d234..86c528e 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -22,6 +22,8 @@ from time import sleep +from tests import launch_polysh + class TestBasic(unittest.TestCase): def localhost(self, nr_localhost): diff --git a/tests/test_command_line.py b/tests/test_command_line.py index 5c3b339..72f919a 100644 --- a/tests/test_command_line.py +++ b/tests/test_command_line.py @@ -20,7 +20,7 @@ import pexpect import os -from polysh_tests import launch_polysh +from tests import launch_polysh class TestCommandLine(unittest.TestCase): diff --git a/tests/test_control_commands.py b/tests/test_control_commands.py index 671f178..1481fc5 100644 --- a/tests/test_control_commands.py +++ b/tests/test_control_commands.py @@ -19,7 +19,8 @@ import os import unittest import pexpect -from polysh_tests import launch_polysh + +from tests import launch_polysh class TestControlCommands(unittest.TestCase): diff --git a/tests/test_display_names.py b/tests/test_display_names.py index 867b5cb..07fcc50 100644 --- a/tests/test_display_names.py +++ b/tests/test_display_names.py @@ -18,7 +18,8 @@ import unittest import pexpect -from polysh_tests import launch_polysh + +from tests import launch_polysh class TestDisplayNames(unittest.TestCase): diff --git a/tests/test_host_syntax.py b/tests/test_host_syntax.py index 2f81cc2..9a8e7c4 100644 --- a/tests/test_host_syntax.py +++ b/tests/test_host_syntax.py @@ -18,7 +18,8 @@ import unittest import pexpect -from polysh_tests import launch_polysh + +from tests import launch_polysh class TestHostSyntax(unittest.TestCase): diff --git a/tests/test_non_interactive.py b/tests/test_non_interactive.py index 60de515..7d896d8 100644 --- a/tests/test_non_interactive.py +++ b/tests/test_non_interactive.py @@ -18,7 +18,8 @@ import unittest import pexpect -from polysh_tests import launch_polysh + +from tests import launch_polysh class TestNonInteractive(unittest.TestCase): diff --git a/tests/test_password_file.py b/tests/test_password_file.py index c377dce..1977780 100644 --- a/tests/test_password_file.py +++ b/tests/test_password_file.py @@ -19,7 +19,8 @@ import os import unittest import pexpect -from polysh_tests import launch_polysh + +from tests import launch_polysh SSH_ARG = """--ssh=bash -c ' read -p password: -s PASSWD;