diff --git a/test_collections/matter/sdk_tests/support/python_testing/models/rpc_client/test_harness_client.py b/test_collections/matter/sdk_tests/support/python_testing/models/rpc_client/test_harness_client.py index fb6fa7e..fa37ba2 100644 --- a/test_collections/matter/sdk_tests/support/python_testing/models/rpc_client/test_harness_client.py +++ b/test_collections/matter/sdk_tests/support/python_testing/models/rpc_client/test_harness_client.py @@ -35,9 +35,9 @@ class TestRunnerHooks: def main() -> None: - # Load python_testing/scripts/sdk as a module. This folder is where all python - # script are located - sys.path.append("/root/python_testing/scripts/sdk") + # Load python_testing/scripts as a module. This folder is where all python scripts + # are located + sys.path.append("/root/python_testing/scripts") test_args = sys.argv[2:] config = parse_matter_test_args(test_args) @@ -49,11 +49,12 @@ def main() -> None: if sys.argv[1] == "commission": commission(config) else: - run_test(script_name=sys.argv[1], class_name=sys.argv[2], config=config) + run_test(script_path=sys.argv[1], class_name=sys.argv[2], config=config) -def run_test(script_name: str, class_name: str, config: MatterTestConfig) -> None: - module = importlib.import_module(script_name) +def run_test(script_path: str, class_name: str, config: MatterTestConfig) -> None: + # For a script_path like 'custom/TC_XYZ' the module is 'custom.TC_XYZ' + module = importlib.import_module(script_path.replace("/", ".")) TestClassReference = getattr(module, class_name) BaseManager.register(TestRunnerHooks.__name__) diff --git a/test_collections/matter/sdk_tests/support/python_testing/models/test_case.py b/test_collections/matter/sdk_tests/support/python_testing/models/test_case.py index 0d93b44..8bf8bd6 100644 --- a/test_collections/matter/sdk_tests/support/python_testing/models/test_case.py +++ b/test_collections/matter/sdk_tests/support/python_testing/models/test_case.py @@ -18,6 +18,7 @@ from enum import IntEnum from inspect import iscoroutinefunction from multiprocessing.managers import BaseManager +from pathlib import Path from socket import SocketIO from typing import Any, Optional, Type, TypeVar @@ -244,8 +245,13 @@ async def execute(self) -> None: f"Missing file path for python test {self.python_test.name}" ) + # get script path including folder (sdk or custom) and excluding extension + test_script_relative_path = Path( + *self.python_test.path.parts[-2:] + ).with_suffix("") + command = [ - f"{RUNNER_CLASS_PATH} {self.python_test.path.stem}" + f"{RUNNER_CLASS_PATH} {test_script_relative_path}" f" {self.python_test.class_name} --tests test_{self.python_test.name}" ]