From 23856723d02b72444e254542e0d9bb2a77d93680 Mon Sep 17 00:00:00 2001 From: hiltonlima <116589806+hiltonlima@users.noreply.github.com> Date: Wed, 3 Jul 2024 13:33:56 -0300 Subject: [PATCH] Update test start hooks (#34140) * Update test start hooks * Restyled by autopep8 --------- Co-authored-by: Restyled.io --- scripts/py_matter_yamltests/matter_yamltests/hooks.py | 5 ++++- scripts/tests/chipyaml/tests_logger.py | 2 +- src/python_testing/hello_external_runner.py | 2 +- src/python_testing/matter_testing_support.py | 5 +++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/py_matter_yamltests/matter_yamltests/hooks.py b/scripts/py_matter_yamltests/matter_yamltests/hooks.py index 9b202c7e94d122..3d25cfff9c06c1 100644 --- a/scripts/py_matter_yamltests/matter_yamltests/hooks.py +++ b/scripts/py_matter_yamltests/matter_yamltests/hooks.py @@ -104,7 +104,7 @@ def stop(self, duration: int): """ pass - def test_start(self, filename: str, name: str, count: int): + def test_start(self, filename: str, name: str, count: int, steps: list[str] = []): """ This method is called when the runner starts running a single test. @@ -118,6 +118,9 @@ def test_start(self, filename: str, name: str, count: int): count: int The number of steps from the test that will be run. + + steps: list[str] + The computed test step names """ pass diff --git a/scripts/tests/chipyaml/tests_logger.py b/scripts/tests/chipyaml/tests_logger.py index ff8ea0b41cec01..1d9480127df180 100755 --- a/scripts/tests/chipyaml/tests_logger.py +++ b/scripts/tests/chipyaml/tests_logger.py @@ -161,7 +161,7 @@ def start(self, count: int): def stop(self, duration: int): print(self.__strings.stop.format(runned=self.__runned, skipped=self.__skipped, duration=duration)) - def test_start(self, filename: str, name: str, count: int): + def test_start(self, filename: str, name: str, count: int, steps: list[str] = []): print(self.__strings.test_start.format(name=click.style(name, bold=True), count=click.style(count, bold=True))) if self.__use_test_harness_log_format: diff --git a/src/python_testing/hello_external_runner.py b/src/python_testing/hello_external_runner.py index 648ba5a85ff4aa..5f00eeb287a543 100755 --- a/src/python_testing/hello_external_runner.py +++ b/src/python_testing/hello_external_runner.py @@ -59,7 +59,7 @@ def start(self, count: int): def stop(self, duration: int): self.stop_called = True - def test_start(self, filename: str, name: str, count: int): + def test_start(self, filename: str, name: str, count: int, steps: list[str] = []): self.test_start_called = True def test_stop(self, exception: Exception, duration: int): diff --git a/src/python_testing/matter_testing_support.py b/src/python_testing/matter_testing_support.py index 623ec9e8e44518..796397c57e0458 100644 --- a/src/python_testing/matter_testing_support.py +++ b/src/python_testing/matter_testing_support.py @@ -274,7 +274,7 @@ def start(self, count: int): def stop(self, duration: int): logging.info(f'Finished test set, ran for {duration}ms') - def test_start(self, filename: str, name: str, count: int): + def test_start(self, filename: str, name: str, count: int, steps: list[str] = []): logging.info(f'Starting test from {filename}: {name} - {count} steps') def test_stop(self, exception: Exception, duration: int): @@ -740,7 +740,8 @@ def setup_test(self): num_steps = 1 if steps is None else len(steps) filename = inspect.getfile(self.__class__) desc = self.get_test_desc(test_name) - self.runner_hook.test_start(filename=filename, name=desc, count=num_steps) + steps_descriptions = [] if steps is None else [step.description for step in steps] + self.runner_hook.test_start(filename=filename, name=desc, count=num_steps, steps=steps_descriptions) # If we don't have defined steps, we're going to start the one and only step now # if there are steps defined by the test, rely on the test calling the step() function # to indicates how it is proceeding