From e37118985067d93412c2f02c5bd71937d0422218 Mon Sep 17 00:00:00 2001 From: cecille Date: Wed, 14 Feb 2024 15:39:21 -0500 Subject: [PATCH 1/4] Python testing: Fix skip_ to use test plan numbers --- src/python_testing/matter_testing_support.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/python_testing/matter_testing_support.py b/src/python_testing/matter_testing_support.py index 2f3ca96d12038d..fc55e58a3c0bb4 100644 --- a/src/python_testing/matter_testing_support.py +++ b/src/python_testing/matter_testing_support.py @@ -1008,9 +1008,11 @@ def skip_all_remaining_steps(self, starting_step): 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) + starting_step = [idx for idx, step in enumerate(steps) if step.test_plan_number == starting_step][0] + remaining = steps[starting_step:] + 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 From eb18b1f57076875e7f5daa70112a7a123b19ca1b Mon Sep 17 00:00:00 2001 From: C Freeman Date: Thu, 15 Feb 2024 10:31:20 -0500 Subject: [PATCH 2/4] Update src/python_testing/matter_testing_support.py Co-authored-by: Terence Hampson --- src/python_testing/matter_testing_support.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/python_testing/matter_testing_support.py b/src/python_testing/matter_testing_support.py index fc55e58a3c0bb4..772c2b9cd5bdd2 100644 --- a/src/python_testing/matter_testing_support.py +++ b/src/python_testing/matter_testing_support.py @@ -1009,8 +1009,13 @@ def skip_all_remaining_steps(self, starting_step): it easier to validate against the test plan for correctness. ''' steps = self.get_test_steps(self.current_test_info.name) - starting_step = [idx for idx, step in enumerate(steps) if step.test_plan_number == starting_step][0] - remaining = steps[starting_step:] + for idx, step in enumerate(steps): + if step.test_plan_number == starting_step: + starting_step_idx = idx + break + else: + raise TestingExpection("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) From c197ec6ec6cbcc21bab2f7f9374d63aaf2df8b50 Mon Sep 17 00:00:00 2001 From: cecille Date: Thu, 15 Feb 2024 10:43:29 -0500 Subject: [PATCH 3/4] address review comments --- src/python_testing/matter_testing_support.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/python_testing/matter_testing_support.py b/src/python_testing/matter_testing_support.py index 772c2b9cd5bdd2..1a6b91e7baad47 100644 --- a/src/python_testing/matter_testing_support.py +++ b/src/python_testing/matter_testing_support.py @@ -1001,20 +1001,21 @@ 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 definted 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. ''' steps = self.get_test_steps(self.current_test_info.name) for idx, step in enumerate(steps): - if step.test_plan_number == starting_step: + if step.test_plan_number == starting_step_number: starting_step_idx = idx break else: - raise TestingExpection("skip_all_remaining_steps was provided with invalid starting_step_num") + 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) From c950a00212028d1f6c88c8acd04c5eb553b6ee93 Mon Sep 17 00:00:00 2001 From: C Freeman Date: Thu, 15 Feb 2024 10:55:20 -0500 Subject: [PATCH 4/4] Update src/python_testing/matter_testing_support.py Co-authored-by: Terence Hampson --- src/python_testing/matter_testing_support.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/matter_testing_support.py b/src/python_testing/matter_testing_support.py index 1a6b91e7baad47..e30a7b4eb57ecc 100644 --- a/src/python_testing/matter_testing_support.py +++ b/src/python_testing/matter_testing_support.py @@ -1004,7 +1004,7 @@ def skip_step(self, step): def skip_all_remaining_steps(self, starting_step_number): ''' Skips all remaining test steps starting with provided starting step - starting_step_number gives the first step to be skipped, as definted in the TestStep.test_plan_number + 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.