Skip to content

Commit

Permalink
Update test start hooks (#34140)
Browse files Browse the repository at this point in the history
* Update test start hooks

* Restyled by autopep8

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Sep 8, 2024
1 parent 5cbb84f commit 2385672
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
5 changes: 4 additions & 1 deletion scripts/py_matter_yamltests/matter_yamltests/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion scripts/tests/chipyaml/tests_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/python_testing/hello_external_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 3 additions & 2 deletions src/python_testing/matter_testing_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2385672

Please sign in to comment.