From 8d30071d3b3e9449e36c0c8d80dd6ee1d52b0aa7 Mon Sep 17 00:00:00 2001 From: C Freeman Date: Thu, 15 Feb 2024 14:43:21 -0500 Subject: [PATCH] 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 * address review comments * Update src/python_testing/matter_testing_support.py Co-authored-by: Terence Hampson --------- Co-authored-by: Terence Hampson --- src/python_testing/matter_testing_support.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/python_testing/matter_testing_support.py b/src/python_testing/matter_testing_support.py index 1515f0310d3302..5a5e9db1820845 100644 --- a/src/python_testing/matter_testing_support.py +++ b/src/python_testing/matter_testing_support.py @@ -1014,16 +1014,24 @@ def skip_step(self, step): 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