From 20f90c561f4b582a28c75265473f1e3b618c188a Mon Sep 17 00:00:00 2001 From: Joshua Villasenor Date: Wed, 31 May 2023 11:08:07 -0700 Subject: [PATCH] Update documentation and typing for request parameter. --- .../py_matter_yamltests/matter_yamltests/hooks.py | 15 ++++++++------- scripts/tests/yaml/tests_logger.py | 7 ++++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/scripts/py_matter_yamltests/matter_yamltests/hooks.py b/scripts/py_matter_yamltests/matter_yamltests/hooks.py index 3ecb8a1babd4ed..6017dd68ad8f2f 100644 --- a/scripts/py_matter_yamltests/matter_yamltests/hooks.py +++ b/scripts/py_matter_yamltests/matter_yamltests/hooks.py @@ -14,6 +14,7 @@ # limitations under the License. from .errors import TestStepError +from .parser import TestStep class TestParserHooks(): @@ -143,18 +144,18 @@ def step_skipped(self, name: str, expression: str): """ pass - def step_start(self, request): + def step_start(self, request: TestStep): """ This method is called when the runner starts running a step from the test. Parameters ---------- - name: str - The name of the test step that is starting. + request: TestStep + The original request as defined by the test step. """ pass - def step_success(self, logger, logs, duration: int, request): + def step_success(self, logger, logs, duration: int, request: TestStep): """ This method is called when running a step succeeds. @@ -169,12 +170,12 @@ def step_success(self, logger, logs, duration: int, request): duration: int How long it took to run the test step, in milliseconds. - request: + request: TestStep The original request as defined by the test step. """ pass - def step_failure(self, logger, logs, duration: int, request, received): + def step_failure(self, logger, logs, duration: int, request: TestStep, received): """ This method is called when running a step fails. @@ -189,7 +190,7 @@ def step_failure(self, logger, logs, duration: int, request, received): duration: int How long it took to run the test step, in milliseconds. - request: + request: TestStep The original request as defined by the test step. received: diff --git a/scripts/tests/yaml/tests_logger.py b/scripts/tests/yaml/tests_logger.py index 8cb74f025cfe6f..4815a9815288d6 100755 --- a/scripts/tests/yaml/tests_logger.py +++ b/scripts/tests/yaml/tests_logger.py @@ -23,6 +23,7 @@ import click from matter_yamltests.errors import TestStepError, TestStepKeyError from matter_yamltests.hooks import TestParserHooks, TestRunnerHooks, WebSocketRunnerHooks +from matter_yamltests.parser import TestStep def _strikethrough(str): @@ -193,7 +194,7 @@ def step_skipped(self, name: str, expression: str): self.__index += 1 self.__skipped += 1 - def step_start(self, request): + def step_start(self, request: TestStep): if self.__use_test_harness_log_format: print(self.__strings.test_harness_step_start.format(index=self.__index, name=request.label)) @@ -211,7 +212,7 @@ def step_unknown(self): self.__runned += 1 - def step_success(self, logger, logs, duration: int, request): + def step_success(self, logger, logs, duration: int, request: TestStep): print(self.__strings.step_result.format(state=_SUCCESS, duration=duration)) self.__print_results(logger) @@ -230,7 +231,7 @@ def step_success(self, logger, logs, duration: int, request): self.__errors += logger.errors self.__runned += 1 - def step_failure(self, logger, logs, duration: int, request, received): + def step_failure(self, logger, logs, duration: int, request: TestStep, received): print(self.__strings.step_result.format(state=_FAILURE, duration=duration)) self.__print_results(logger)