diff --git a/scripts/py_matter_yamltests/matter_yamltests/hooks.py b/scripts/py_matter_yamltests/matter_yamltests/hooks.py index b68ae35fd6ce94..c1b1fa53446ab5 100644 --- a/scripts/py_matter_yamltests/matter_yamltests/hooks.py +++ b/scripts/py_matter_yamltests/matter_yamltests/hooks.py @@ -13,14 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .errors import TestStepError from .parser import TestStep class TestParserHooks(): __test__ = False - def start(self, count: int): + def parsing_start(self, count: int): """ This method is called when the parser starts parsing a set of files. @@ -31,7 +30,7 @@ def start(self, count: int): """ pass - def stop(self, duration: int): + def parsing_stop(self, duration: int): """ This method is called when the parser is done parsing a set of files. @@ -42,7 +41,7 @@ def stop(self, duration: int): """ pass - def test_start(self, name: str): + def test_parsing_start(self, name: str): """ This method is called when the parser starts parsing a single file. @@ -53,20 +52,20 @@ def test_start(self, name: str): """ pass - def test_failure(self, exception: TestStepError, duration: int): + def test_parsing_failure(self, exception: Exception, duration: int): """ This method is called when parsing a single file fails. Parameters ---------- - exception: TestStepError + exception: Exception An exception describing why parsing the file has failed. duration: int How long it took to parse the file, in milliseconds. """ pass - def test_success(self, duration: int): + def test_parsing_success(self, duration: int): """ This method is called when parsing a single file succeeds. diff --git a/scripts/py_matter_yamltests/matter_yamltests/parser_builder.py b/scripts/py_matter_yamltests/matter_yamltests/parser_builder.py index 70a4eb01705447..819406f2d43cfd 100644 --- a/scripts/py_matter_yamltests/matter_yamltests/parser_builder.py +++ b/scripts/py_matter_yamltests/matter_yamltests/parser_builder.py @@ -70,7 +70,7 @@ def __init__(self, config: TestParserBuilderConfig = TestParserBuilderConfig()): self.done = False def __iter__(self): - self.__config.hooks.start(len(self.__tests)) + self.__config.hooks.parsing_start(len(self.__tests)) return self def __next__(self): @@ -78,7 +78,7 @@ def __next__(self): return self.__get_test_parser(self.__tests.pop(0)) if not self.done: - self.__config.hooks.stop(round(self.__duration)) + self.__config.hooks.parsing_stop(round(self.__duration)) self.done = True raise StopIteration @@ -89,7 +89,7 @@ def __get_test_parser(self, test_file: str) -> TestParser: parser = None exception = None try: - self.__config.hooks.test_start(test_file) + self.__config.hooks.test_parsing_start(test_file) parser = TestParser(test_file, self.__config.parser_config) except Exception as e: exception = e @@ -97,10 +97,10 @@ def __get_test_parser(self, test_file: str) -> TestParser: duration = round((time.time() - start) * 1000, 0) self.__duration += duration if exception: - self.__config.hooks.test_failure(exception, duration) + self.__config.hooks.test_parsing_failure(exception, duration) if self.__config.options.stop_on_error: raise StopIteration return None - self.__config.hooks.test_success(duration) + self.__config.hooks.test_parsing_success(duration) return parser diff --git a/scripts/py_matter_yamltests/test_parser_builder.py b/scripts/py_matter_yamltests/test_parser_builder.py index 186dfad98f0def..40b29357221f43 100644 --- a/scripts/py_matter_yamltests/test_parser_builder.py +++ b/scripts/py_matter_yamltests/test_parser_builder.py @@ -72,19 +72,19 @@ def __init__(self): self.test_failure_count = 0 self.test_success_count = 0 - def start(self, count): + def parsing_start(self, count): self.start_count += 1 - def stop(self, duration): + def parsing_stop(self, duration): self.stop_count += 1 - def test_start(self, name): + def test_parsing_start(self, name): self.test_start_count += 1 - def test_success(self, duration): + def test_parsing_success(self, duration): self.test_success_count += 1 - def test_failure(self, exception, duration): + def test_parsing_failure(self, exception, duration): self.test_failure_count += 1 diff --git a/scripts/tests/yaml/tests_logger.py b/scripts/tests/yaml/tests_logger.py index f01b0d28ec26a4..ff8ea0b41cec01 100755 --- a/scripts/tests/yaml/tests_logger.py +++ b/scripts/tests/yaml/tests_logger.py @@ -67,19 +67,19 @@ def __init__(self): self.__errors = 0 self.__strings = ParserStrings() - def start(self, count: int): + def parsing_start(self, count: int): print(self.__strings.start.format(count=count)) - def stop(self, duration: int): + def parsing_stop(self, duration: int): state = _FAILURE if self.__errors else _SUCCESS success = click.style(self.__success, bold=True) errors = click.style(self.__errors, bold=True) print(self.__strings.stop.format(state=state, successes=success, errors=errors, duration=duration)) - def test_start(self, name: str): + def test_parsing_start(self, name: str): print(self.__strings.test_start.format(name=name), end='') - def test_failure(self, exception: Exception, duration: int): + def test_parsing_failure(self, exception: Exception, duration: int): print(self.__strings.test_result.format(state=_FAILURE, duration=duration)) try: @@ -91,7 +91,7 @@ def test_failure(self, exception: Exception, duration: int): self.__errors += 1 - def test_success(self, duration: int): + def test_parsing_success(self, duration: int): print(self.__strings.test_result.format(state=_SUCCESS, duration=duration)) self.__success += 1