From 4529da7aee1989fe0caaea06b27af1294fbbc754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Sat, 2 May 2026 09:28:40 +0200 Subject: [PATCH] Restructure: consolidate everything inside testium/ package MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move src/lib/ → src/testium/runtime/ (internal plumbing) Move src/testium/libs/ → src/testium/api/ (public SDK for test scripts) Move src/py_func/ → src/testium/py_func/ (Python subprocess) Move src/lua_func/ → src/testium/lua_func/ (Lua subprocess data) The package now ships as a single coherent unit instead of four sibling top-level packages (testium, lib, py_func, lua_func) — pip install gives a clean site-packages/testium/ with no namespace pollution; .lua files travel with the wheel via package_data; the wheel installs cleanly and `testium -b` runs end-to-end including py_func subprocesses and entry-point exporter plugins. Naming: - runtime/ (internal, no API guarantees) clearer than lib/ - api/ (public SDK consumed as `import api.testium as tm`) clearer than libs/ Imports updated en masse: from lib. → from runtime. and from libs. → from api., plus the importlib.import_module("libs.*") strings in test_item_console.py and test_item_runtime_plot.py. Test/example scripts (helper_lib.py, parallel.py, post_execution.py) and the fake_exporter test suite migrated too. paths.py: subproc_path() now returns testium_path() — both point at the testium package directory since the subprocesses live inside. pyproject.toml: removed exclude=["lua_func", "py_func"] (no longer needed), added package-data for testium.lua_func/*.lua, removed the license classifier (PEP 639 conflict with license expression). Subprocess isolation contract: py_func/ and lua_func/ may only import runtime/ and their own modules — never interpreter/, main_win/, api/, or testium/. Enforced by test/validation/items/isolation/ which runs a py_func that statically scans subprocess source files for forbidden imports. The contract holds today; the test prevents future drift. Co-Authored-By: Claude Opus 4.7 --- CLAUDE.md | 25 ++++++- doc/examples/dummy/post_execution.py | 2 +- src/pyproject.toml | 5 +- src/{lib => testium/api}/__init__.py | 0 src/testium/{libs => api}/console.py | 2 +- src/testium/{libs => api}/console_ssh.py | 2 +- src/testium/{libs => api}/raw_tcp_console.py | 2 +- src/testium/{libs => api}/runtime_plot.py | 4 +- src/testium/{libs => api}/termconsole.py | 2 +- src/testium/{libs => api}/testium.py | 10 +-- src/testium/interpreter/batch.py | 4 +- src/testium/interpreter/process.py | 8 +-- .../test_items/item_actions/__init__.py | 2 +- .../interpreter/test_items/test_item.py | 4 +- .../interpreter/test_items/test_item_check.py | 4 +- .../test_items/test_item_choices_dialog.py | 4 +- .../test_items/test_item_console.py | 14 ++-- .../interpreter/test_items/test_item_cycle.py | 4 +- .../test_items/test_item_dialog_base.py | 2 +- .../interpreter/test_items/test_item_git.py | 2 +- .../interpreter/test_items/test_item_group.py | 4 +- .../test_items/test_item_image_dialog.py | 4 +- .../test_items/test_item_json_rpc/__init__.py | 2 +- .../test_item_json_rpc/jsonrpc_adapters.py | 6 +- .../interpreter/test_items/test_item_let.py | 4 +- .../test_items/test_item_lua_func.py | 4 +- .../test_items/test_item_msg_dialog.py | 2 +- .../test_items/test_item_note_dialog.py | 4 +- .../test_items/test_item_parallel.py | 6 +- .../test_items/test_item_py_func.py | 4 +- .../test_items/test_item_question_dialog.py | 2 +- .../test_items/test_item_report.py | 2 +- .../interpreter/test_items/test_item_run.py | 4 +- .../test_items/test_item_runtime_plot.py | 6 +- .../interpreter/test_items/test_item_sleep.py | 4 +- .../test_items/test_item_tested_references.py | 4 +- .../test_items/test_item_unittest.py | 6 +- .../test_items/test_item_value_dialog.py | 4 +- .../interpreter/test_items/test_result.py | 2 +- .../interpreter/test_report/report_export.py | 2 +- .../test_report/report_export_junit.py | 2 +- .../interpreter/test_report/test_report.py | 4 +- src/testium/interpreter/test_set.py | 6 +- src/testium/interpreter/utils/api_srv.py | 4 +- src/testium/interpreter/utils/eval.py | 4 +- src/testium/interpreter/utils/include.py | 4 +- .../interpreter/utils/lua_func_exec.py | 2 +- src/testium/interpreter/utils/lua_process.py | 6 +- src/testium/interpreter/utils/params.py | 2 +- src/testium/interpreter/utils/paths.py | 11 ++-- src/testium/interpreter/utils/py_eval.py | 4 +- src/testium/interpreter/utils/py_func_exec.py | 2 +- src/testium/interpreter/utils/py_process.py | 6 +- src/testium/interpreter/utils/settings.py | 2 +- src/testium/interpreter/utils/template.py | 2 +- src/testium/interpreter/utils/test_ctrl.py | 2 +- src/testium/interpreter/utils/test_init.py | 4 +- src/testium/interpreter/utils/version.py | 2 +- src/testium/interpreter/utils/yaml_load.py | 4 +- src/testium/{libs => lua_func}/__init__.py | 0 src/{ => testium}/lua_func/handle.lua | 0 src/{ => testium}/lua_func/json-rpc.lua | 0 src/{ => testium}/lua_func/main.lua | 0 src/{ => testium}/lua_func/tm.lua | 0 src/{ => testium}/lua_func/utils.lua | 0 src/testium/main_win/test_file_manager.py | 2 +- src/testium/main_win/test_tree.py | 4 +- .../test_tree_items/test_tree_item.py | 2 +- src/testium/main_win/testium_win.py | 8 +-- src/testium/main_win/text_log.py | 2 +- src/{ => testium}/py_func/__init__.py | 2 +- src/{ => testium}/py_func/__main__.py | 0 src/{ => testium}/py_func/func_call.py | 2 +- src/{ => testium}/py_func/handle.py | 4 +- src/{ => testium}/py_func/tm.py | 4 +- src/testium/runtime/__init__.py | 0 src/{lib => testium/runtime}/api.py | 0 src/{lib => testium/runtime}/jrpc.py | 4 +- .../runtime}/stdout_redirect.py | 2 +- src/{lib => testium/runtime}/string_queue.py | 0 src/{lib => testium/runtime}/tum_except.py | 0 .../console serial/terminal_bug_reproducer.py | 2 +- .../terminal_bug_reproducer.py | 2 +- test/validation/items/common/helper_lib.py | 2 +- .../items/isolation/check_isolation.py | 65 +++++++++++++++++++ test/validation/items/isolation/param.yaml | 1 + test/validation/items/isolation/test.tum | 8 +++ test/validation/items/parallel/parallel.py | 2 +- 88 files changed, 230 insertions(+), 139 deletions(-) rename src/{lib => testium/api}/__init__.py (100%) rename src/testium/{libs => api}/console.py (96%) rename src/testium/{libs => api}/console_ssh.py (99%) rename src/testium/{libs => api}/raw_tcp_console.py (98%) rename src/testium/{libs => api}/runtime_plot.py (99%) rename src/testium/{libs => api}/termconsole.py (95%) rename src/testium/{libs => api}/testium.py (92%) rename src/testium/{libs => lua_func}/__init__.py (100%) rename src/{ => testium}/lua_func/handle.lua (100%) rename src/{ => testium}/lua_func/json-rpc.lua (100%) rename src/{ => testium}/lua_func/main.lua (100%) rename src/{ => testium}/lua_func/tm.lua (100%) rename src/{ => testium}/lua_func/utils.lua (100%) rename src/{ => testium}/py_func/__init__.py (96%) rename src/{ => testium}/py_func/__main__.py (100%) rename src/{ => testium}/py_func/func_call.py (96%) rename src/{ => testium}/py_func/handle.py (96%) rename src/{ => testium}/py_func/tm.py (98%) create mode 100644 src/testium/runtime/__init__.py rename src/{lib => testium/runtime}/api.py (100%) rename src/{lib => testium/runtime}/jrpc.py (99%) rename src/{lib => testium/runtime}/stdout_redirect.py (99%) rename src/{lib => testium/runtime}/string_queue.py (100%) rename src/{lib => testium/runtime}/tum_except.py (100%) create mode 100644 test/validation/items/isolation/check_isolation.py create mode 100644 test/validation/items/isolation/param.yaml create mode 100644 test/validation/items/isolation/test.tum diff --git a/CLAUDE.md b/CLAUDE.md index 6176c4d..67f212d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -109,9 +109,28 @@ All dialog items (`dialog_image`, `dialog_question`, `dialog_references`, `dialo | `src/testium/interpreter/test_items/test_item_parallel.py` | `parallel` and `parallel_branch` items | | `src/testium/interpreter/utils/globdict.py` | Global variable dict | | `src/testium/interpreter/utils/termlog.py` | Terminal color output | -| `src/lib/stdout_redirect.py` | `StdioRedirect` singleton (`stdio_redir`) | -| `src/lib/string_queue.py` | Thread-safe string buffer used for stdout redirection | -| `src/testium/libs/testium.py` | Public API for test scripts (`tm.*`) | +| `src/testium/runtime/stdout_redirect.py` | `StdioRedirect` singleton (`stdio_redir`) | +| `src/testium/runtime/string_queue.py` | Thread-safe string buffer used for stdout redirection | +| `src/testium/api/testium.py` | Public API for test scripts (`tm.*`) | +| `src/testium/py_func/` | Python subprocess for `py_func` items (sandboxed: imports only `runtime/` and `py_func/`) | +| `src/testium/lua_func/` | Lua subprocess scripts for `lua_func` items | + +## Package layout + +The whole project is a single Python package under `src/testium/`: + +``` +src/testium/ +├── __init__.py / __main__.py +├── runtime/ internal plumbing (jrpc, stdout_redirect, string_queue, tum_except, api) +├── api/ public SDK exposed to test scripts (`import api.testium as tm`) +├── interpreter/ test execution engine (NOT visible to py_func/lua_func) +├── main_win/ GUI (NOT visible to py_func/lua_func) +├── py_func/ subprocess code for python_func items +└── lua_func/ subprocess scripts for lua_func items (data files) +``` + +`subproc_path()` and `testium_path()` both return the package directory. The py_func subprocess is launched with cwd=that directory and `python3 py_func`. The contract that `py_func/` and `lua_func/` only depend on `runtime/` (no `interpreter`, `main_win`, `api`, `testium`) is enforced by `test/validation/items/isolation/`. ## GUI icons (main_win) diff --git a/doc/examples/dummy/post_execution.py b/doc/examples/dummy/post_execution.py index ab383d9..af4c56f 100644 --- a/doc/examples/dummy/post_execution.py +++ b/doc/examples/dummy/post_execution.py @@ -1,5 +1,5 @@ -import libs.testium as tm +import api.testium as tm def post_exec(): print('Success !!!!') diff --git a/src/pyproject.toml b/src/pyproject.toml index 20a2b01..9c0c207 100644 --- a/src/pyproject.toml +++ b/src/pyproject.toml @@ -13,7 +13,6 @@ license-files = ["../LICENSE"] classifiers = [ "Development Status :: 5 - Production/Stable", "Programming Language :: Python", - "License :: OSI Approved :: European Union Public Licence 1.2 (EUPL 1.2)", ] dependencies = [ "setuptools", @@ -36,7 +35,9 @@ testium = "testium:main" [tool.setuptools.packages.find] where=["."] -exclude=["lua_func", "py_func"] + +[tool.setuptools.package-data] +"testium.lua_func" = ["*.lua"] [tool.setuptools.dynamic] version = {file = ["VERSION"]} diff --git a/src/lib/__init__.py b/src/testium/api/__init__.py similarity index 100% rename from src/lib/__init__.py rename to src/testium/api/__init__.py diff --git a/src/testium/libs/console.py b/src/testium/api/console.py similarity index 96% rename from src/testium/libs/console.py rename to src/testium/api/console.py index 24aa038..924da1c 100755 --- a/src/testium/libs/console.py +++ b/src/testium/api/console.py @@ -245,7 +245,7 @@ A {classname}.close() is missing somewhere in your code !'.format(classname=type if not sys.platform.startswith('win'): # import SshConsole if pexpect is installed try: - from libs.console_ssh import SshConsole + from api.console_ssh import SshConsole except ImportError: pass diff --git a/src/testium/libs/console_ssh.py b/src/testium/api/console_ssh.py similarity index 99% rename from src/testium/libs/console_ssh.py rename to src/testium/api/console_ssh.py index fb8c800..482b4e3 100755 --- a/src/testium/libs/console_ssh.py +++ b/src/testium/api/console_ssh.py @@ -8,7 +8,7 @@ import os import pexpect from pexpect import ExceptionPexpect, TIMEOUT, EOF, spawn -from libs.console import Console +from api.console import Console # Exception classes used by this module. diff --git a/src/testium/libs/raw_tcp_console.py b/src/testium/api/raw_tcp_console.py similarity index 98% rename from src/testium/libs/raw_tcp_console.py rename to src/testium/api/raw_tcp_console.py index d4b96c5..3d8e907 100644 --- a/src/testium/libs/raw_tcp_console.py +++ b/src/testium/api/raw_tcp_console.py @@ -3,7 +3,7 @@ import sys import socket import traceback -from libs.console import * +from api.console import * class RawTCPConsole(Console): TYPE = 'rawtcp' diff --git a/src/testium/libs/runtime_plot.py b/src/testium/api/runtime_plot.py similarity index 99% rename from src/testium/libs/runtime_plot.py rename to src/testium/api/runtime_plot.py index 42fc6df..fdaef8c 100644 --- a/src/testium/libs/runtime_plot.py +++ b/src/testium/api/runtime_plot.py @@ -16,9 +16,9 @@ import numpy as np import matplotlib.dates as mdates from datetime import datetime, timedelta, timezone -import libs.testium as tm +import api.testium as tm from interpreter.test_items.test_result import TestValue -from lib.tum_except import ETUMRuntimeError +from runtime.tum_except import ETUMRuntimeError from interpreter.utils.py_func_exec import PyFuncExecEngine from interpreter.utils.api_srv import api_request from interpreter.utils.eval import post_evaluate diff --git a/src/testium/libs/termconsole.py b/src/testium/api/termconsole.py similarity index 95% rename from src/testium/libs/termconsole.py rename to src/testium/api/termconsole.py index ea6f753..6b0a47e 100644 --- a/src/testium/libs/termconsole.py +++ b/src/testium/api/termconsole.py @@ -10,7 +10,7 @@ import os ourPath = os.path.dirname(__file__) sys.path.append(ourPath) -from libs.console import (Console, BytesStore, TIMEOUT_NULL) +from api.console import (Console, BytesStore, TIMEOUT_NULL) class TermConsole(Console): TYPE = 'term' diff --git a/src/testium/libs/testium.py b/src/testium/api/testium.py similarity index 92% rename from src/testium/libs/testium.py rename to src/testium/api/testium.py index 11ca2ba..175c20a 100644 --- a/src/testium/libs/testium.py +++ b/src/testium/api/testium.py @@ -4,7 +4,7 @@ import sys import textwrap from time import monotonic import interpreter.utils.globdict as globdict -from lib.tum_except import (ETUMSyntaxError) +from runtime.tum_except import (ETUMSyntaxError) ############################################################################### # Console helper functions @@ -14,7 +14,7 @@ def add_console(console): ''' Function which adds a ``Console`` class instance to *testium* :param console: The ``Console`` instance. - :type console: ``libs.console.Console`` or child class instance + :type console: ``api.console.Console`` or child class instance :return: No returned value ''' @@ -48,7 +48,7 @@ def console(name): :param name: The name of the ``Console`` instance. :type name: str :return: The ``Console`` or child class object - :rtype: ``libs.console.Console`` or child class instance + :rtype: ``api.console.Console`` or child class instance """ cons = None for c in globdict.gd('console_instances', []): @@ -65,7 +65,7 @@ def add_plot(plot: object) -> None: ''' Function which adds a ``RuntimePlot`` class instance to *testium* :param plot: The ``RuntimePlot`` instance. - :type plot: ``libs.runtime_plot.RuntimePlot`` or child class instance + :type plot: ``api.runtime_plot.RuntimePlot`` or child class instance :return: No returned value ''' @@ -99,7 +99,7 @@ def plot(name: str) -> object: :param name: The name of the ``RuntimePlot`` instance. :type name: str :return: The ``RuntimePlot`` or child class object - :rtype: ``libs.runtime_plot.RuntimePlot`` or child class instance + :rtype: ``api.runtime_plot.RuntimePlot`` or child class instance """ plot = None for g in globdict.gd('plot_instances', []): diff --git a/src/testium/interpreter/batch.py b/src/testium/interpreter/batch.py index a44b63c..9f9b25b 100644 --- a/src/testium/interpreter/batch.py +++ b/src/testium/interpreter/batch.py @@ -9,8 +9,8 @@ from multiprocessing import Queue from interpreter.process import TestProcess from interpreter.utils.test_ctrl import TestSetController -from lib.tum_except import ETUMFileError, ETUMRuntimeError -from lib.stdout_redirect import stdio_redir +from runtime.tum_except import ETUMFileError, ETUMRuntimeError +from runtime.stdout_redirect import stdio_redir class Batch: diff --git a/src/testium/interpreter/process.py b/src/testium/interpreter/process.py index ee470a2..859f026 100644 --- a/src/testium/interpreter/process.py +++ b/src/testium/interpreter/process.py @@ -6,9 +6,9 @@ from threading import Thread from time import sleep import copy -from lib.string_queue import StringQueue -from lib.tum_except import print_exception, ETUMRuntimeError, ETUMSyntaxError -import libs.testium as tm +from runtime.string_queue import StringQueue +from runtime.tum_except import print_exception, ETUMRuntimeError, ETUMSyntaxError +import api.testium as tm import interpreter.utils.globdict as globdict from interpreter.utils.params import expanse from interpreter.utils.test_ctrl import TestSetController @@ -26,7 +26,7 @@ from interpreter.utils.test_init import ( from interpreter.utils.constants import TestItemType as cst_type from interpreter.test_set import TestSet from interpreter.utils.include import TUMLoader, TUMLoaderNoIncludes, TUMLoaderRawIncludes -from lib.stdout_redirect import stdio_redir +from runtime.stdout_redirect import stdio_redir from interpreter.utils.template import template_to_test from interpreter.utils.yaml_load import yaml_load from interpreter.utils.py_eval import eval_process_init diff --git a/src/testium/interpreter/test_items/item_actions/__init__.py b/src/testium/interpreter/test_items/item_actions/__init__.py index 98c7080..d503d63 100644 --- a/src/testium/interpreter/test_items/item_actions/__init__.py +++ b/src/testium/interpreter/test_items/item_actions/__init__.py @@ -1,4 +1,4 @@ -from lib.tum_except import ETUMSyntaxError +from runtime.tum_except import ETUMSyntaxError from interpreter.test_items.test_item import TestItem, test_run, test_data from interpreter.test_items.test_result import TestResult, TestValue from interpreter.test_items.item_actions.action import TestItemAction diff --git a/src/testium/interpreter/test_items/test_item.py b/src/testium/interpreter/test_items/test_item.py index 7adb8b0..4b47d9c 100644 --- a/src/testium/interpreter/test_items/test_item.py +++ b/src/testium/interpreter/test_items/test_item.py @@ -3,11 +3,11 @@ from time import sleep import yaml from copy import deepcopy from interpreter.test_items.test_result import TestResult, TestValue -import libs.testium as tm +import api.testium as tm from interpreter.utils.params import TestItemParams from interpreter.utils.constants import TestItemType as cst_type from interpreter.utils.eval import eval_to_boolean, evaluate, post_evaluate -from lib.tum_except import ETUMSyntaxError, item_load_context +from runtime.tum_except import ETUMSyntaxError, item_load_context LOG_TEST_STOP = '<----- step "{}" finished' LOG_TEST_START = '-----> step "{}" started' diff --git a/src/testium/interpreter/test_items/test_item_check.py b/src/testium/interpreter/test_items/test_item_check.py index e30b2d6..a7bae10 100644 --- a/src/testium/interpreter/test_items/test_item_check.py +++ b/src/testium/interpreter/test_items/test_item_check.py @@ -1,8 +1,8 @@ from interpreter.test_items.test_item import (TestItem, test_run) from interpreter.test_items.test_result import TestValue -from lib.tum_except import ETUMSyntaxError, item_load_context -import libs.testium as tm +from runtime.tum_except import ETUMSyntaxError, item_load_context +import api.testium as tm from interpreter.utils.constants import TestItemType as cst from interpreter.utils.eval import evaluate diff --git a/src/testium/interpreter/test_items/test_item_choices_dialog.py b/src/testium/interpreter/test_items/test_item_choices_dialog.py index d00cc2f..32d32e0 100644 --- a/src/testium/interpreter/test_items/test_item_choices_dialog.py +++ b/src/testium/interpreter/test_items/test_item_choices_dialog.py @@ -2,8 +2,8 @@ from interpreter.test_items.test_item import test_run from interpreter.test_items.test_result import TestValue from interpreter.test_items.test_item_dialog_base import TestItemDialogBase, _is_text_mode, _is_interactive from interpreter.utils.constants import TestItemType as cst -from lib.tum_except import item_load_context -import libs.testium as tm +from runtime.tum_except import item_load_context +import api.testium as tm class TestItemChoicesDialog(TestItemDialogBase): diff --git a/src/testium/interpreter/test_items/test_item_console.py b/src/testium/interpreter/test_items/test_item_console.py index 0923d4f..e264707 100644 --- a/src/testium/interpreter/test_items/test_item_console.py +++ b/src/testium/interpreter/test_items/test_item_console.py @@ -3,9 +3,9 @@ import os import importlib import traceback -import libs.testium as tm -from lib.tum_except import ETUMSyntaxError -from lib.stdout_redirect import stdio_redir +import api.testium as tm +from runtime.tum_except import ETUMSyntaxError +from runtime.stdout_redirect import stdio_redir from interpreter.test_items.test_item import test_run from interpreter.test_items.item_actions import TestItemActions from interpreter.test_items.item_actions.action import TestItemAction @@ -345,17 +345,17 @@ class TestItemConsole(TestItemActions): self.actions_token = {} global console - console = importlib.import_module("libs.console") + console = importlib.import_module("api.console") if not sys.platform.startswith("win"): global console_ssh - console_ssh = importlib.import_module("libs.console_ssh") + console_ssh = importlib.import_module("api.console_ssh") global termconsole - termconsole = importlib.import_module("libs.termconsole") + termconsole = importlib.import_module("api.termconsole") global raw_tcp_console - raw_tcp_console = importlib.import_module("libs.raw_tcp_console") + raw_tcp_console = importlib.import_module("api.raw_tcp_console") self.actions_token["console_name"] = self._prms.getParam( "console_name", required=True diff --git a/src/testium/interpreter/test_items/test_item_cycle.py b/src/testium/interpreter/test_items/test_item_cycle.py index 2b439bc..b3d3369 100644 --- a/src/testium/interpreter/test_items/test_item_cycle.py +++ b/src/testium/interpreter/test_items/test_item_cycle.py @@ -1,11 +1,11 @@ import traceback -from lib.tum_except import ETUMSyntaxError, ETUMRuntimeError +from runtime.tum_except import ETUMSyntaxError, ETUMRuntimeError from interpreter.utils.py_func_exec import PyFuncExecEngine from interpreter.utils.api_srv import api_request from interpreter.test_items.test_item import TestItem, test_run from interpreter.test_items.test_result import TestResult, TestValue -import libs.testium as tm +import api.testium as tm from interpreter.utils.params import TestItemParams from interpreter.utils.constants import TestItemType as cst diff --git a/src/testium/interpreter/test_items/test_item_dialog_base.py b/src/testium/interpreter/test_items/test_item_dialog_base.py index 5e580cc..6c470a9 100644 --- a/src/testium/interpreter/test_items/test_item_dialog_base.py +++ b/src/testium/interpreter/test_items/test_item_dialog_base.py @@ -1,6 +1,6 @@ import multiprocessing -import libs.testium as tm +import api.testium as tm from interpreter.test_items.test_item import TestItem diff --git a/src/testium/interpreter/test_items/test_item_git.py b/src/testium/interpreter/test_items/test_item_git.py index b5b809a..7486777 100644 --- a/src/testium/interpreter/test_items/test_item_git.py +++ b/src/testium/interpreter/test_items/test_item_git.py @@ -1,7 +1,7 @@ from interpreter.test_items.test_item import (TestItem, test_run) from interpreter.test_items.test_result import (TestValue) from interpreter.utils.constants import TestItemType as cst -from lib.tum_except import ETUMParamError, ETUMSyntaxError +from runtime.tum_except import ETUMParamError, ETUMSyntaxError import interpreter.utils.version as git class TestItemGit(TestItem): diff --git a/src/testium/interpreter/test_items/test_item_group.py b/src/testium/interpreter/test_items/test_item_group.py index 81e89d5..e288945 100644 --- a/src/testium/interpreter/test_items/test_item_group.py +++ b/src/testium/interpreter/test_items/test_item_group.py @@ -1,8 +1,8 @@ from interpreter.test_items.test_item import (TestItem, test_run) from interpreter.test_items.test_result import (TestResult, TestValue) from interpreter.utils.constants import TestItemType as cst -from lib.tum_except import ETUMSyntaxError -import libs.testium as tm +from runtime.tum_except import ETUMSyntaxError +import api.testium as tm class TestItemGroup(TestItem): def __init__(self, dict_cycle, parent = None, status_queue=None, filename=""): diff --git a/src/testium/interpreter/test_items/test_item_image_dialog.py b/src/testium/interpreter/test_items/test_item_image_dialog.py index 6956d9e..ea726e4 100644 --- a/src/testium/interpreter/test_items/test_item_image_dialog.py +++ b/src/testium/interpreter/test_items/test_item_image_dialog.py @@ -4,8 +4,8 @@ from interpreter.test_items.test_item import test_run from interpreter.test_items.test_result import TestValue from interpreter.test_items.test_item_dialog_base import TestItemDialogBase, _is_text_mode, _is_interactive from interpreter.utils.constants import TestItemType as cst -from lib.tum_except import item_load_context -import libs.testium as tm +from runtime.tum_except import item_load_context +import api.testium as tm class TestItemImageDialog(TestItemDialogBase): diff --git a/src/testium/interpreter/test_items/test_item_json_rpc/__init__.py b/src/testium/interpreter/test_items/test_item_json_rpc/__init__.py index 2bb77f7..d4631dc 100644 --- a/src/testium/interpreter/test_items/test_item_json_rpc/__init__.py +++ b/src/testium/interpreter/test_items/test_item_json_rpc/__init__.py @@ -2,7 +2,7 @@ import sys import traceback from random import randint -from lib.tum_except import ETUMSyntaxError +from runtime.tum_except import ETUMSyntaxError from interpreter.test_items.test_item import TestItem, test_run from interpreter.test_items.test_result import TestResult, TestValue diff --git a/src/testium/interpreter/test_items/test_item_json_rpc/jsonrpc_adapters.py b/src/testium/interpreter/test_items/test_item_json_rpc/jsonrpc_adapters.py index 1a479d3..e27f168 100644 --- a/src/testium/interpreter/test_items/test_item_json_rpc/jsonrpc_adapters.py +++ b/src/testium/interpreter/test_items/test_item_json_rpc/jsonrpc_adapters.py @@ -3,9 +3,9 @@ import socket import re import struct -from lib.tum_except import ETUMRuntimeError -import libs.testium as tm -from libs.console import Console +from runtime.tum_except import ETUMRuntimeError +import api.testium as tm +from api.console import Console def is_ip_address(address): diff --git a/src/testium/interpreter/test_items/test_item_let.py b/src/testium/interpreter/test_items/test_item_let.py index 49f3dc1..11c6c4f 100644 --- a/src/testium/interpreter/test_items/test_item_let.py +++ b/src/testium/interpreter/test_items/test_item_let.py @@ -5,8 +5,8 @@ import time from interpreter.test_items.test_item import (TestItem, test_run) from interpreter.test_items.test_result import (TestResult, TestValue) -from lib.tum_except import ETUMSyntaxError, item_load_context -import libs.testium as tm +from runtime.tum_except import ETUMSyntaxError, item_load_context +import api.testium as tm from interpreter.utils.constants import TestItemType as cst class TestItemLet(TestItem): diff --git a/src/testium/interpreter/test_items/test_item_lua_func.py b/src/testium/interpreter/test_items/test_item_lua_func.py index 0bbb443..c4da3b0 100644 --- a/src/testium/interpreter/test_items/test_item_lua_func.py +++ b/src/testium/interpreter/test_items/test_item_lua_func.py @@ -4,10 +4,10 @@ import traceback import pprint import textwrap -from lib.tum_except import ETUMSyntaxError, ETUMRuntimeError, item_load_context +from runtime.tum_except import ETUMSyntaxError, ETUMRuntimeError, item_load_context from interpreter.test_items.test_item import TestItem, test_run from interpreter.test_items.test_result import TestValue -import libs.testium as tm +import api.testium as tm from interpreter.utils.lua_func_exec import LuaFuncExecEngine from interpreter.utils.api_srv import api_request from interpreter.utils.constants import TestItemType as cst diff --git a/src/testium/interpreter/test_items/test_item_msg_dialog.py b/src/testium/interpreter/test_items/test_item_msg_dialog.py index 110c6d9..7c1d618 100644 --- a/src/testium/interpreter/test_items/test_item_msg_dialog.py +++ b/src/testium/interpreter/test_items/test_item_msg_dialog.py @@ -5,7 +5,7 @@ from interpreter.test_items.test_item import test_run from interpreter.test_items.test_result import TestValue from interpreter.test_items.test_item_dialog_base import TestItemDialogBase, _is_text_mode, _is_interactive from interpreter.utils.constants import TestItemType as cst -from lib.tum_except import item_load_context +from runtime.tum_except import item_load_context class TestItemMsgDialog(TestItemDialogBase): diff --git a/src/testium/interpreter/test_items/test_item_note_dialog.py b/src/testium/interpreter/test_items/test_item_note_dialog.py index 88aa190..982016c 100644 --- a/src/testium/interpreter/test_items/test_item_note_dialog.py +++ b/src/testium/interpreter/test_items/test_item_note_dialog.py @@ -2,8 +2,8 @@ from interpreter.test_items.test_item import test_run from interpreter.test_items.test_result import TestValue from interpreter.test_items.test_item_dialog_base import TestItemDialogBase, _is_text_mode, _is_interactive from interpreter.utils.constants import TestItemType as cst -from lib.tum_except import item_load_context -import libs.testium as tm +from runtime.tum_except import item_load_context +import api.testium as tm class TestItemNoteDialog(TestItemDialogBase): diff --git a/src/testium/interpreter/test_items/test_item_parallel.py b/src/testium/interpreter/test_items/test_item_parallel.py index 19050b4..c7c0163 100644 --- a/src/testium/interpreter/test_items/test_item_parallel.py +++ b/src/testium/interpreter/test_items/test_item_parallel.py @@ -6,9 +6,9 @@ from interpreter.test_items.test_item import test_run from interpreter.test_items.test_result import TestResult, TestValue from interpreter.utils.constants import TestItemType as cst from interpreter.utils.eval import eval_to_boolean -from lib.tum_except import ETUMSyntaxError -from lib.string_queue import StringQueue -from lib.stdout_redirect import stdio_redir +from runtime.tum_except import ETUMSyntaxError +from runtime.string_queue import StringQueue +from runtime.stdout_redirect import stdio_redir class TestItemParallelBranch(TestItemContainer): diff --git a/src/testium/interpreter/test_items/test_item_py_func.py b/src/testium/interpreter/test_items/test_item_py_func.py index e560d49..dbd2bd6 100644 --- a/src/testium/interpreter/test_items/test_item_py_func.py +++ b/src/testium/interpreter/test_items/test_item_py_func.py @@ -4,10 +4,10 @@ import time import pprint import textwrap -from lib.tum_except import ETUMSyntaxError, ETUMRuntimeError, item_load_context +from runtime.tum_except import ETUMSyntaxError, ETUMRuntimeError, item_load_context from interpreter.test_items.test_item import TestItem, test_run from interpreter.test_items.test_result import TestValue -import libs.testium as tm +import api.testium as tm from interpreter.utils.py_func_exec import PyFuncExecEngine from interpreter.utils.api_srv import api_request from interpreter.utils.constants import TestItemType as cst diff --git a/src/testium/interpreter/test_items/test_item_question_dialog.py b/src/testium/interpreter/test_items/test_item_question_dialog.py index beec964..19a393f 100644 --- a/src/testium/interpreter/test_items/test_item_question_dialog.py +++ b/src/testium/interpreter/test_items/test_item_question_dialog.py @@ -2,7 +2,7 @@ from interpreter.test_items.test_item import test_run from interpreter.test_items.test_result import TestValue from interpreter.test_items.test_item_dialog_base import TestItemDialogBase, _is_text_mode, _is_interactive from interpreter.utils.constants import TestItemType as cst -from lib.tum_except import item_load_context +from runtime.tum_except import item_load_context class TestItemQuestionDialog(TestItemDialogBase): diff --git a/src/testium/interpreter/test_items/test_item_report.py b/src/testium/interpreter/test_items/test_item_report.py index b96f365..ebe7afb 100644 --- a/src/testium/interpreter/test_items/test_item_report.py +++ b/src/testium/interpreter/test_items/test_item_report.py @@ -1,7 +1,7 @@ from interpreter.test_items.test_item import (TestItem, test_run) from interpreter.test_items.test_result import (TestValue) -from lib.tum_except import ETUMSyntaxError +from runtime.tum_except import ETUMSyntaxError from interpreter.utils.constants import TestItemType as cst from interpreter.test_report.test_report import Export diff --git a/src/testium/interpreter/test_items/test_item_run.py b/src/testium/interpreter/test_items/test_item_run.py index 39f805a..feaa758 100644 --- a/src/testium/interpreter/test_items/test_item_run.py +++ b/src/testium/interpreter/test_items/test_item_run.py @@ -8,9 +8,9 @@ import traceback from interpreter.test_items.test_item import (TestItem, test_run) from interpreter.test_items.test_result import (TestValue) -import libs.testium as tm +import api.testium as tm from interpreter.utils.constants import TestItemType as cst -from lib.tum_except import ETUMSyntaxError, ETUMRuntimeError, item_load_context +from runtime.tum_except import ETUMSyntaxError, ETUMRuntimeError, item_load_context def nowInBetween(start, end): diff --git a/src/testium/interpreter/test_items/test_item_runtime_plot.py b/src/testium/interpreter/test_items/test_item_runtime_plot.py index 8415f78..11c921e 100644 --- a/src/testium/interpreter/test_items/test_item_runtime_plot.py +++ b/src/testium/interpreter/test_items/test_item_runtime_plot.py @@ -3,8 +3,8 @@ import importlib import traceback from functools import wraps -import libs.testium as tm -from lib.tum_except import ETUMSyntaxError, item_load_context +import api.testium as tm +from runtime.tum_except import ETUMSyntaxError, item_load_context from interpreter.test_items.test_item import TestItem, test_run from interpreter.test_items.test_result import TestResult, TestValue from interpreter.test_items.item_actions import TestItemActions @@ -235,4 +235,4 @@ class TestItemPlot(TestItemActions): self.actions_token = self._prms.getParam("plot_name", required=True) global runtime_plot - runtime_plot = importlib.import_module("libs.runtime_plot") + runtime_plot = importlib.import_module("api.runtime_plot") diff --git a/src/testium/interpreter/test_items/test_item_sleep.py b/src/testium/interpreter/test_items/test_item_sleep.py index fcd7f77..4aabef9 100644 --- a/src/testium/interpreter/test_items/test_item_sleep.py +++ b/src/testium/interpreter/test_items/test_item_sleep.py @@ -3,11 +3,11 @@ from time import sleep from datetime import timedelta from multiprocessing import Process, Pipe -import libs.testium as tm +import api.testium as tm from interpreter.test_items.test_item import (TestItem, test_run) from interpreter.test_items.test_result import (TestValue) from interpreter.utils.constants import TestItemType as cst -from lib.tum_except import ETUMSyntaxError, ETUMRuntimeError, item_load_context +from runtime.tum_except import ETUMSyntaxError, ETUMRuntimeError, item_load_context class TestItemSleep(TestItem): """sleep item usage. diff --git a/src/testium/interpreter/test_items/test_item_tested_references.py b/src/testium/interpreter/test_items/test_item_tested_references.py index f9f1e2a..2130e96 100644 --- a/src/testium/interpreter/test_items/test_item_tested_references.py +++ b/src/testium/interpreter/test_items/test_item_tested_references.py @@ -2,8 +2,8 @@ from interpreter.test_items.test_item import test_run from interpreter.test_items.test_result import TestValue from interpreter.test_items.test_item_dialog_base import TestItemDialogBase, _is_text_mode, _is_interactive from interpreter.utils.constants import TestItemType as cst -from lib.tum_except import item_load_context -import libs.testium as tm +from runtime.tum_except import item_load_context +import api.testium as tm class TestItemTestedRefsDialog(TestItemDialogBase): diff --git a/src/testium/interpreter/test_items/test_item_unittest.py b/src/testium/interpreter/test_items/test_item_unittest.py index b6b5e29..4300988 100644 --- a/src/testium/interpreter/test_items/test_item_unittest.py +++ b/src/testium/interpreter/test_items/test_item_unittest.py @@ -4,14 +4,14 @@ from unittest import (TestCase, TestSuite, TextTestRunner, TextTestResult) from unittest.loader import defaultTestLoader -import libs.testium as tm -from lib.tum_except import (ETUMFileError) +import api.testium as tm +from runtime.tum_except import (ETUMFileError) from interpreter.utils.modules import load_source from interpreter.test_items.test_item import (TestItem, test_run, LOG_TEST_STOP, LOG_TEST_START) from interpreter.test_items.test_result import (TestResult, TestValue) from interpreter.test_items.test_item import test_data from interpreter.utils.constants import TestItemType as cst -from lib.stdout_redirect import stdio_redir +from runtime.stdout_redirect import stdio_redir class UnittestResult(TextTestResult): """Test result adapted for unittest test""" diff --git a/src/testium/interpreter/test_items/test_item_value_dialog.py b/src/testium/interpreter/test_items/test_item_value_dialog.py index 18026ff..69de01c 100644 --- a/src/testium/interpreter/test_items/test_item_value_dialog.py +++ b/src/testium/interpreter/test_items/test_item_value_dialog.py @@ -2,8 +2,8 @@ from interpreter.test_items.test_item import test_run from interpreter.test_items.test_result import TestValue from interpreter.test_items.test_item_dialog_base import TestItemDialogBase, _is_text_mode, _is_interactive from interpreter.utils.constants import TestItemType as cst -from lib.tum_except import item_load_context -import libs.testium as tm +from runtime.tum_except import item_load_context +import api.testium as tm class TestItemValueDialog(TestItemDialogBase): diff --git a/src/testium/interpreter/test_items/test_result.py b/src/testium/interpreter/test_items/test_result.py index d626d4d..e5eea5d 100644 --- a/src/testium/interpreter/test_items/test_result.py +++ b/src/testium/interpreter/test_items/test_result.py @@ -1,4 +1,4 @@ -from lib.tum_except import (ETUMRuntimeError) +from runtime.tum_except import (ETUMRuntimeError) from datetime import datetime from enum import Enum diff --git a/src/testium/interpreter/test_report/report_export.py b/src/testium/interpreter/test_report/report_export.py index 3b9d47e..71c3919 100644 --- a/src/testium/interpreter/test_report/report_export.py +++ b/src/testium/interpreter/test_report/report_export.py @@ -3,7 +3,7 @@ import os import interpreter.test_report.test_report as tr from interpreter.utils.paths import prepare_file_to_save import interpreter.utils.constants as cst -import libs.testium as tm +import api.testium as tm class ReportExport: diff --git a/src/testium/interpreter/test_report/report_export_junit.py b/src/testium/interpreter/test_report/report_export_junit.py index eb52b0e..5f61d91 100644 --- a/src/testium/interpreter/test_report/report_export_junit.py +++ b/src/testium/interpreter/test_report/report_export_junit.py @@ -1,5 +1,5 @@ from junit_xml import (TestSuite, TestCase) -import libs.testium as tm +import api.testium as tm from interpreter.test_items.test_result import (TestValue) import interpreter.test_report.report_export as rpe import interpreter.test_report.test_report as tr diff --git a/src/testium/interpreter/test_report/test_report.py b/src/testium/interpreter/test_report/test_report.py index 68dd6f4..c5901e9 100644 --- a/src/testium/interpreter/test_report/test_report.py +++ b/src/testium/interpreter/test_report/test_report.py @@ -4,8 +4,8 @@ from functools import wraps import sqlite3 from time import (time, sleep) import traceback -from lib.tum_except import (ETUMRuntimeError, ETUMSyntaxError) -from lib.stdout_redirect import stdio_redir +from runtime.tum_except import (ETUMRuntimeError, ETUMSyntaxError) +from runtime.stdout_redirect import stdio_redir from interpreter.utils.params import (expanse) from interpreter.utils.paths import prepare_file_to_save import interpreter.utils.constants as cst diff --git a/src/testium/interpreter/test_set.py b/src/testium/interpreter/test_set.py index 785f846..f222271 100644 --- a/src/testium/interpreter/test_set.py +++ b/src/testium/interpreter/test_set.py @@ -2,13 +2,13 @@ import os import datetime from queue import Queue from interpreter.utils.params import expanse -import libs.testium as tm -from lib.tum_except import ETUMSyntaxError +import api.testium as tm +from runtime.tum_except import ETUMSyntaxError import interpreter.utils.settings as prefs from interpreter.test_report.test_report import TestReport from interpreter.utils.py_func_exec import PyFuncExecEngine from interpreter.utils.api_srv import api_request -from lib.tum_except import ETUMRuntimeError +from runtime.tum_except import ETUMRuntimeError from interpreter.utils.constants import TestItemType as cst_type import interpreter.utils.constants as cst from interpreter.utils.constants import TEST_TYPE_LIST diff --git a/src/testium/interpreter/utils/api_srv.py b/src/testium/interpreter/utils/api_srv.py index 76af6d3..023afb0 100644 --- a/src/testium/interpreter/utils/api_srv.py +++ b/src/testium/interpreter/utils/api_srv.py @@ -1,6 +1,6 @@ -from lib.api import SUPPORTED_API +from runtime.api import SUPPORTED_API -import libs.testium as tm +import api.testium as tm # Fill the api_dict with the function of tm api_dict = {k: getattr(tm, k) for k in SUPPORTED_API if hasattr(tm, k)} diff --git a/src/testium/interpreter/utils/eval.py b/src/testium/interpreter/utils/eval.py index a3e9a42..a53ec2b 100644 --- a/src/testium/interpreter/utils/eval.py +++ b/src/testium/interpreter/utils/eval.py @@ -1,6 +1,6 @@ -import libs.testium as tm +import api.testium as tm from interpreter.utils.py_eval import eval_exec -from lib.tum_except import ETUMSyntaxError, ETUMRuntimeError +from runtime.tum_except import ETUMSyntaxError, ETUMRuntimeError def evaluate(val, **replacement_dict): diff --git a/src/testium/interpreter/utils/include.py b/src/testium/interpreter/utils/include.py index 65e5fee..0fd3d3e 100644 --- a/src/testium/interpreter/utils/include.py +++ b/src/testium/interpreter/utils/include.py @@ -1,8 +1,8 @@ import yaml import os.path -import libs.testium as tm +import api.testium as tm from interpreter.utils.params import expanse -from lib.tum_except import ETUMFileError +from runtime.tum_except import ETUMFileError from interpreter.utils.template import template_to_test from copy import copy from interpreter.utils.globdict import global_dict diff --git a/src/testium/interpreter/utils/lua_func_exec.py b/src/testium/interpreter/utils/lua_func_exec.py index eec2863..c6c58c6 100644 --- a/src/testium/interpreter/utils/lua_func_exec.py +++ b/src/testium/interpreter/utils/lua_func_exec.py @@ -1,6 +1,6 @@ from interpreter.utils.lua_process import LuaProcessBase -from lib.tum_except import ETUMRuntimeError +from runtime.tum_except import ETUMRuntimeError from interpreter.test_items.test_result import TestValue diff --git a/src/testium/interpreter/utils/lua_process.py b/src/testium/interpreter/utils/lua_process.py index 2b919e7..55928bb 100644 --- a/src/testium/interpreter/utils/lua_process.py +++ b/src/testium/interpreter/utils/lua_process.py @@ -4,10 +4,10 @@ import shutil import subprocess import socket -import libs.testium as tm -from lib.jrpc import JsonRpcClient +import api.testium as tm +from runtime.jrpc import JsonRpcClient from interpreter.utils.paths import subproc_path -from lib.tum_except import ETUMRuntimeError +from runtime.tum_except import ETUMRuntimeError from interpreter.utils.paths import sys_app_path_lin, sys_app_path_win def _lua_version(path: str): diff --git a/src/testium/interpreter/utils/params.py b/src/testium/interpreter/utils/params.py index 88372bf..2c66ce3 100644 --- a/src/testium/interpreter/utils/params.py +++ b/src/testium/interpreter/utils/params.py @@ -1,5 +1,5 @@ import interpreter.utils.globdict as globdict -from lib.tum_except import ETUMSyntaxError, ETUMRuntimeError +from runtime.tum_except import ETUMSyntaxError, ETUMRuntimeError glob_eval_func = None diff --git a/src/testium/interpreter/utils/paths.py b/src/testium/interpreter/utils/paths.py index 9b8e929..719788a 100644 --- a/src/testium/interpreter/utils/paths.py +++ b/src/testium/interpreter/utils/paths.py @@ -5,7 +5,7 @@ from pathlib import Path import testium from interpreter.utils.params import expanse import subprocess -import libs.testium as tm +import api.testium as tm def testium_path(): @@ -18,12 +18,9 @@ def testium_path(): return str(Path(tp).parent.resolve()) def subproc_path(): - if getattr(sys, 'frozen', False): - # Exécuté depuis le .exe - return sys._MEIPASS - - tp = inspect.getfile(inspect.getmodule(testium)) - return str(Path(tp).parent.parent.resolve()) + # py_func and lua_func now live inside the testium package; their cwd + # is the testium package root, same as testium_path(). + return testium_path() def prepare_file_to_save(file_name, file_ext=""): iname = file_name diff --git a/src/testium/interpreter/utils/py_eval.py b/src/testium/interpreter/utils/py_eval.py index 76eec6f..def3ebe 100644 --- a/src/testium/interpreter/utils/py_eval.py +++ b/src/testium/interpreter/utils/py_eval.py @@ -1,6 +1,6 @@ from interpreter.utils.py_process import PyProcessBase -from lib.tum_except import ETUMRuntimeError -import libs.testium as tm +from runtime.tum_except import ETUMRuntimeError +import api.testium as tm eval_process = None diff --git a/src/testium/interpreter/utils/py_func_exec.py b/src/testium/interpreter/utils/py_func_exec.py index 1628824..6f64b7b 100644 --- a/src/testium/interpreter/utils/py_func_exec.py +++ b/src/testium/interpreter/utils/py_func_exec.py @@ -1,6 +1,6 @@ from interpreter.utils.py_process import PyProcessBase -from lib.tum_except import ETUMRuntimeError +from runtime.tum_except import ETUMRuntimeError from interpreter.test_items.test_result import TestValue diff --git a/src/testium/interpreter/utils/py_process.py b/src/testium/interpreter/utils/py_process.py index faeef01..1703368 100644 --- a/src/testium/interpreter/utils/py_process.py +++ b/src/testium/interpreter/utils/py_process.py @@ -3,10 +3,10 @@ import shutil import sys import subprocess import socket -from lib.jrpc import JsonRpcClient -import libs.testium as tm +from runtime.jrpc import JsonRpcClient +import api.testium as tm from interpreter.utils.paths import sys_app_path_lin, sys_app_path_win -from lib.tum_except import ETUMRuntimeError +from runtime.tum_except import ETUMRuntimeError from interpreter.utils.paths import testium_path, subproc_path diff --git a/src/testium/interpreter/utils/settings.py b/src/testium/interpreter/utils/settings.py index 72e1c55..b5c87e6 100644 --- a/src/testium/interpreter/utils/settings.py +++ b/src/testium/interpreter/utils/settings.py @@ -2,7 +2,7 @@ import os import configparser import json import platform -from lib.tum_except import ETUMRuntimeError +from runtime.tum_except import ETUMRuntimeError SettingsCompany = 'Testium' SettingsApplication = 'testium' diff --git a/src/testium/interpreter/utils/template.py b/src/testium/interpreter/utils/template.py index 76ff3b5..c7a3173 100644 --- a/src/testium/interpreter/utils/template.py +++ b/src/testium/interpreter/utils/template.py @@ -4,7 +4,7 @@ from jinja2 import Template from jinja2.exceptions import TemplateSyntaxError, TemplateError, UndefinedError from tempfile import TemporaryFile from interpreter.utils.yaml_load import print_yaml -from lib.tum_except import ETUMSyntaxError +from runtime.tum_except import ETUMSyntaxError def template_to_test(filename: str, params: list): diff --git a/src/testium/interpreter/utils/test_ctrl.py b/src/testium/interpreter/utils/test_ctrl.py index d5e1426..6896db8 100644 --- a/src/testium/interpreter/utils/test_ctrl.py +++ b/src/testium/interpreter/utils/test_ctrl.py @@ -1,6 +1,6 @@ from multiprocessing import Queue from queue import Empty -from lib.tum_except import ETUMRuntimeError +from runtime.tum_except import ETUMRuntimeError class TestSetController: diff --git a/src/testium/interpreter/utils/test_init.py b/src/testium/interpreter/utils/test_init.py index e5a62d7..8afab45 100644 --- a/src/testium/interpreter/utils/test_init.py +++ b/src/testium/interpreter/utils/test_init.py @@ -7,13 +7,13 @@ import yaml import copy from interpreter.utils.constants import TestItemType as cst -import libs.testium as tm +import api.testium as tm import interpreter.utils.globdict as globdict import interpreter.utils.settings as prefs from interpreter.utils.paths import testium_path from interpreter.utils.yaml_load import yaml_load from interpreter.utils import clear_recursively -from lib.tum_except import ETUMSyntaxError +from runtime.tum_except import ETUMSyntaxError from interpreter.utils.params import expanse, eval_func_init from interpreter.utils.eval import evaluate from interpreter.utils.version import ( diff --git a/src/testium/interpreter/utils/version.py b/src/testium/interpreter/utils/version.py index d5765db..eee7643 100644 --- a/src/testium/interpreter/utils/version.py +++ b/src/testium/interpreter/utils/version.py @@ -3,7 +3,7 @@ import sys from importlib import import_module import interpreter.utils.settings as prefs -import libs.testium as tm +import api.testium as tm _cached_versions = {} diff --git a/src/testium/interpreter/utils/yaml_load.py b/src/testium/interpreter/utils/yaml_load.py index bcd273c..0502c19 100644 --- a/src/testium/interpreter/utils/yaml_load.py +++ b/src/testium/interpreter/utils/yaml_load.py @@ -1,8 +1,8 @@ from yaml.parser import ParserError from yaml import load, Loader from yaml.scanner import ScannerError -from libs.testium import print_debug -from lib.tum_except import ETUMSyntaxError +from api.testium import print_debug +from runtime.tum_except import ETUMSyntaxError import io diff --git a/src/testium/libs/__init__.py b/src/testium/lua_func/__init__.py similarity index 100% rename from src/testium/libs/__init__.py rename to src/testium/lua_func/__init__.py diff --git a/src/lua_func/handle.lua b/src/testium/lua_func/handle.lua similarity index 100% rename from src/lua_func/handle.lua rename to src/testium/lua_func/handle.lua diff --git a/src/lua_func/json-rpc.lua b/src/testium/lua_func/json-rpc.lua similarity index 100% rename from src/lua_func/json-rpc.lua rename to src/testium/lua_func/json-rpc.lua diff --git a/src/lua_func/main.lua b/src/testium/lua_func/main.lua similarity index 100% rename from src/lua_func/main.lua rename to src/testium/lua_func/main.lua diff --git a/src/lua_func/tm.lua b/src/testium/lua_func/tm.lua similarity index 100% rename from src/lua_func/tm.lua rename to src/testium/lua_func/tm.lua diff --git a/src/lua_func/utils.lua b/src/testium/lua_func/utils.lua similarity index 100% rename from src/lua_func/utils.lua rename to src/testium/lua_func/utils.lua diff --git a/src/testium/main_win/test_file_manager.py b/src/testium/main_win/test_file_manager.py index 616a7e2..4b58aaa 100644 --- a/src/testium/main_win/test_file_manager.py +++ b/src/testium/main_win/test_file_manager.py @@ -10,7 +10,7 @@ from interpreter.process import TestProcess from interpreter.utils.test_ctrl import TestSetController from main_win.test_controller_service import TestControllerService import interpreter.utils.settings as prefs -from lib.tum_except import ETUMFileError, ETUMRuntimeError +from runtime.tum_except import ETUMFileError, ETUMRuntimeError class TestFileManager: diff --git a/src/testium/main_win/test_tree.py b/src/testium/main_win/test_tree.py index 455d3b1..c223d6e 100644 --- a/src/testium/main_win/test_tree.py +++ b/src/testium/main_win/test_tree.py @@ -10,12 +10,12 @@ from PySide6.QtGui import (QFont, QFontInfo) from time import (time) from main_win.test_tree_items.common import (TEST_COLS, TEST_COLS_WITH_TIME) -from lib.tum_except import (ETUMFileError, ETUMSyntaxError) +from runtime.tum_except import (ETUMFileError, ETUMSyntaxError) from main_win.test_controller_service import TestControllerService from main_win.test_tree_items.test_tree_item import make_tree_item from interpreter.test_items.test_result import (TestValue) -import libs.testium as tm +import api.testium as tm import interpreter.utils.settings as prefs from interpreter.utils.constants import TestItemType as cst from interpreter.utils.icons import icon_prefix diff --git a/src/testium/main_win/test_tree_items/test_tree_item.py b/src/testium/main_win/test_tree_items/test_tree_item.py index 5a749ac..f9e4ed0 100644 --- a/src/testium/main_win/test_tree_items/test_tree_item.py +++ b/src/testium/main_win/test_tree_items/test_tree_item.py @@ -5,7 +5,7 @@ from PySide6.QtGui import (QIcon, QPixmap, QBrush, QColor) from PySide6.QtCore import Qt from PySide6.QtWidgets import (QTreeWidgetItem) from interpreter.utils.icons import icon_prefix -from libs.testium import print_warn +from api.testium import print_warn # Maps item_name (from TestItemType.item_name) to visual config. # Keys: icon (required), icon_on (optional 2nd state), expanded, unfoldable, no_breakpoint diff --git a/src/testium/main_win/testium_win.py b/src/testium/main_win/testium_win.py index f51a2f8..8ecb19b 100755 --- a/src/testium/main_win/testium_win.py +++ b/src/testium/main_win/testium_win.py @@ -30,7 +30,7 @@ from main_win.f1_win.d_f1_win import DialogF1 from main_win.test_tree import QTestTree from main_win.test_run.thread_output import ThreadTestOutput -from lib.string_queue import StringQueue +from runtime.string_queue import StringQueue from interpreter.process import TestProcess from interpreter.utils.test_ctrl import TestSetController from interpreter.utils.icons import icon_prefix @@ -38,14 +38,14 @@ from interpreter.utils.icons import icon_prefix from main_win.test_run.outlog import OutLog from main_win.test_run.test_run import ThreadTestStatus import interpreter.utils.settings as prefs -from lib.stdout_redirect import stdio_redir -import libs.testium as tm +from runtime.stdout_redirect import stdio_redir +import api.testium as tm from interpreter.utils.test_init import ( env_init, locate_report_file, ) from interpreter.utils.version import get_testium_version -from lib.tum_except import ETUMFileError, ETUMRuntimeError +from runtime.tum_except import ETUMFileError, ETUMRuntimeError from main_win.test_controller_service import TestControllerService from main_win.test_runner import TestRunner, TestState from main_win.test_file_manager import TestFileManager diff --git a/src/testium/main_win/text_log.py b/src/testium/main_win/text_log.py index 84546ab..aaeadfc 100644 --- a/src/testium/main_win/text_log.py +++ b/src/testium/main_win/text_log.py @@ -6,7 +6,7 @@ from PySide6.QtGui import QCursor, QDesktopServices, QFont from main_win.text_log_highlighter import TextLogHighlighter -import libs.testium as tm +import api.testium as tm class QTextLog(QPlainTextEdit): def __init__(self, parent): diff --git a/src/py_func/__init__.py b/src/testium/py_func/__init__.py similarity index 96% rename from src/py_func/__init__.py rename to src/testium/py_func/__init__.py index dffa97e..f8e9b35 100755 --- a/src/py_func/__init__.py +++ b/src/testium/py_func/__init__.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import multiprocessing from py_func.tm import _init_api, _remote_print -from lib.stdout_redirect import stdio_redir +from runtime.stdout_redirect import stdio_redir class TcpStdOut: diff --git a/src/py_func/__main__.py b/src/testium/py_func/__main__.py similarity index 100% rename from src/py_func/__main__.py rename to src/testium/py_func/__main__.py diff --git a/src/py_func/func_call.py b/src/testium/py_func/func_call.py similarity index 96% rename from src/py_func/func_call.py rename to src/testium/py_func/func_call.py index 4cb580d..75afc7f 100644 --- a/src/py_func/func_call.py +++ b/src/testium/py_func/func_call.py @@ -5,7 +5,7 @@ from pathlib import Path import importlib import traceback -from lib.tum_except import ETUMRuntimeError, ETUMSyntaxError +from runtime.tum_except import ETUMRuntimeError, ETUMSyntaxError from py_func import tm diff --git a/src/py_func/handle.py b/src/testium/py_func/handle.py similarity index 96% rename from src/py_func/handle.py rename to src/testium/py_func/handle.py index 758e19d..9108223 100644 --- a/src/py_func/handle.py +++ b/src/testium/py_func/handle.py @@ -7,8 +7,8 @@ import math import json import traceback -from lib.jrpc import JsonRpcSrv -from lib.tum_except import ETUMRuntimeError, print_exception +from runtime.jrpc import JsonRpcSrv +from runtime.tum_except import ETUMRuntimeError, print_exception import py_func.tm as tm from py_func.func_call import func_exec diff --git a/src/py_func/tm.py b/src/testium/py_func/tm.py similarity index 98% rename from src/py_func/tm.py rename to src/testium/py_func/tm.py index 68cfed4..cdfea6d 100644 --- a/src/py_func/tm.py +++ b/src/testium/py_func/tm.py @@ -2,8 +2,8 @@ import json import sys from py_func.handle import FuncHandler -from lib.tum_except import ETUMRuntimeError -from lib.api import SUPPORTED_API +from runtime.tum_except import ETUMRuntimeError +from runtime.api import SUPPORTED_API thismodule = sys.modules[__name__] _func_call_thread = None diff --git a/src/testium/runtime/__init__.py b/src/testium/runtime/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/lib/api.py b/src/testium/runtime/api.py similarity index 100% rename from src/lib/api.py rename to src/testium/runtime/api.py diff --git a/src/lib/jrpc.py b/src/testium/runtime/jrpc.py similarity index 99% rename from src/lib/jrpc.py rename to src/testium/runtime/jrpc.py index 0820184..b3b45d8 100644 --- a/src/lib/jrpc.py +++ b/src/testium/runtime/jrpc.py @@ -6,11 +6,11 @@ import itertools from time import sleep from typing import Callable, Any try: - import libs.testium as tm + import api.testium as tm except: import py_func.tm as tm -from lib.tum_except import ETUMRuntimeError +from runtime.tum_except import ETUMRuntimeError """Lightweight JSON-RPC 2.0 helpers over TCP sockets. diff --git a/src/lib/stdout_redirect.py b/src/testium/runtime/stdout_redirect.py similarity index 99% rename from src/lib/stdout_redirect.py rename to src/testium/runtime/stdout_redirect.py index b827622..41e9fd8 100644 --- a/src/lib/stdout_redirect.py +++ b/src/testium/runtime/stdout_redirect.py @@ -1,7 +1,7 @@ import sys import threading from threading import (Thread, Event) -from lib.string_queue import StringQueue +from runtime.string_queue import StringQueue from time import (sleep) diff --git a/src/lib/string_queue.py b/src/testium/runtime/string_queue.py similarity index 100% rename from src/lib/string_queue.py rename to src/testium/runtime/string_queue.py diff --git a/src/lib/tum_except.py b/src/testium/runtime/tum_except.py similarity index 100% rename from src/lib/tum_except.py rename to src/testium/runtime/tum_except.py diff --git a/test/robustness/console serial/terminal_bug_reproducer.py b/test/robustness/console serial/terminal_bug_reproducer.py index f973851..4cd917e 100644 --- a/test/robustness/console serial/terminal_bug_reproducer.py +++ b/test/robustness/console serial/terminal_bug_reproducer.py @@ -1,4 +1,4 @@ -import libs.testium as tm +import api.testium as tm def RetreiveData(console_name): print("--------------- retrieving data ---------------") diff --git a/test/robustness/console terminal/terminal_bug_reproducer.py b/test/robustness/console terminal/terminal_bug_reproducer.py index f973851..4cd917e 100644 --- a/test/robustness/console terminal/terminal_bug_reproducer.py +++ b/test/robustness/console terminal/terminal_bug_reproducer.py @@ -1,4 +1,4 @@ -import libs.testium as tm +import api.testium as tm def RetreiveData(console_name): print("--------------- retrieving data ---------------") diff --git a/test/validation/items/common/helper_lib.py b/test/validation/items/common/helper_lib.py index dba98b7..197d97c 100644 --- a/test/validation/items/common/helper_lib.py +++ b/test/validation/items/common/helper_lib.py @@ -1,4 +1,4 @@ -import libs.testium as libtm +import api.testium as libtm def check_os(expected_os): diff --git a/test/validation/items/isolation/check_isolation.py b/test/validation/items/isolation/check_isolation.py new file mode 100644 index 0000000..73af760 --- /dev/null +++ b/test/validation/items/isolation/check_isolation.py @@ -0,0 +1,65 @@ +"""Static check that py_func/ and lua_func/ subprocess code does not depend +on testium internals. The contract is: + + py_func/*.py may import: py_func.*, runtime.*, plus stdlib/3rd-party + lua_func/*.lua may require: lua_func/, plus lua stdlib + +Forbidden top-level modules: interpreter, main_win, api, testium. +""" + +import ast +import os +import re + +FORBIDDEN_PY = {"interpreter", "main_win", "api", "testium"} +FORBIDDEN_LUA = {"interpreter", "main_win", "api", "testium"} + + +def _collect_py_imports(path): + with open(path, "r", encoding="utf-8") as f: + tree = ast.parse(f.read(), filename=path) + out = set() + for node in ast.walk(tree): + if isinstance(node, ast.Import): + for n in node.names: + out.add(n.name.split(".")[0]) + elif isinstance(node, ast.ImportFrom): + if node.level == 0 and node.module: + out.add(node.module.split(".")[0]) + return out + + +def _collect_lua_requires(path): + with open(path, "r", encoding="utf-8") as f: + text = f.read() + return {m.split(".")[0] for m in re.findall(r'require\s*\(?\s*["\']([^"\']+)["\']', text)} + + +def check_isolation(testium_dir): + failures = [] + + py_dir = os.path.join(testium_dir, "py_func") + for root, _, files in os.walk(py_dir): + for f in files: + if not f.endswith(".py"): + continue + p = os.path.join(root, f) + leaks = _collect_py_imports(p) & FORBIDDEN_PY + if leaks: + failures.append(f"py_func/{os.path.relpath(p, py_dir)} leaks: {sorted(leaks)}") + + lua_dir = os.path.join(testium_dir, "lua_func") + for root, _, files in os.walk(lua_dir): + for f in files: + if not f.endswith(".lua"): + continue + p = os.path.join(root, f) + leaks = _collect_lua_requires(p) & FORBIDDEN_LUA + if leaks: + failures.append(f"lua_func/{os.path.relpath(p, lua_dir)} leaks: {sorted(leaks)}") + + if failures: + for line in failures: + print(f" - {line}") + return False + return True diff --git a/test/validation/items/isolation/param.yaml b/test/validation/items/isolation/param.yaml new file mode 100644 index 0000000..0af0f7f --- /dev/null +++ b/test/validation/items/isolation/param.yaml @@ -0,0 +1 @@ +no_param: Null diff --git a/test/validation/items/isolation/test.tum b/test/validation/items/isolation/test.tum new file mode 100644 index 0000000..9a0b1bb --- /dev/null +++ b/test/validation/items/isolation/test.tum @@ -0,0 +1,8 @@ +- py_func: + name: py_func/lua_func do not depend on testium internals + file: $(test_path)$(psep)check_isolation.py + func_name: check_isolation + key: $(test)_PASS + param: + - $(testium_path) + expected_result: True diff --git a/test/validation/items/parallel/parallel.py b/test/validation/items/parallel/parallel.py index 0d5cc5e..f8a7527 100644 --- a/test/validation/items/parallel/parallel.py +++ b/test/validation/items/parallel/parallel.py @@ -1,5 +1,5 @@ import time -import libs.testium as tm +import api.testium as tm def sleep_func(duration):