Python testing: Fix skip_ to use test plan numbers (#32130)
* Python testing: Fix skip_ to use test plan numbers
* Update src/python_testing/matter_testing_support.py
Co-authored-by: Terence Hampson <thampson@google.com>
* address review comments
* Update src/python_testing/matter_testing_support.py
Co-authored-by: Terence Hampson <thampson@google.com>
---------
Co-authored-by: Terence Hampson <thampson@google.com>
diff --git a/src/python_testing/matter_testing_support.py b/src/python_testing/matter_testing_support.py
index 1515f03..5a5e9db 100644
--- a/src/python_testing/matter_testing_support.py
+++ b/src/python_testing/matter_testing_support.py
@@ -1014,16 +1014,24 @@
self.step(step)
self.mark_current_step_skipped()
- def skip_all_remaining_steps(self, starting_step):
+ def skip_all_remaining_steps(self, starting_step_number):
''' Skips all remaining test steps starting with provided starting step
- starting_step must be provided, and is not derived intentionally. By providing argument
+ starting_step_number gives the first step to be skipped, as defined in the TestStep.test_plan_number
+ starting_step_number must be provided, and is not derived intentionally. By providing argument
test is more deliberately identifying where test skips are starting from, making
it easier to validate against the test plan for correctness.
'''
- last_step = len(self.get_test_steps(self.current_test_info.name)) + 1
- for index in range(starting_step, last_step):
- self.skip_step(index)
+ steps = self.get_test_steps(self.current_test_info.name)
+ for idx, step in enumerate(steps):
+ if step.test_plan_number == starting_step_number:
+ starting_step_idx = idx
+ break
+ else:
+ asserts.fail("skip_all_remaining_steps was provided with invalid starting_step_num")
+ remaining = steps[starting_step_idx:]
+ for step in remaining:
+ self.skip_step(step.test_plan_number)
def step(self, step: typing.Union[int, str]):
test_name = self.current_test_info.name