diff --git a/src/python_testing/TC_TIMESYNC_2_1.py b/src/python_testing/TC_TIMESYNC_2_1.py index ba3021a0fa0034..0f2fdba4d603f5 100644 --- a/src/python_testing/TC_TIMESYNC_2_1.py +++ b/src/python_testing/TC_TIMESYNC_2_1.py @@ -32,8 +32,8 @@ import chip.clusters as Clusters from chip.clusters.Types import NullValue -from matter_testing_support import (MatterBaseTest, default_matter_test_main, has_attribute, has_cluster, - run_if_endpoint_matches, utc_time_in_matter_epoch) +from matter_testing_support import (MatterBaseTest, default_matter_test_main, has_attribute, has_cluster, run_if_endpoint_matches, + utc_time_in_matter_epoch) from mobly import asserts diff --git a/src/python_testing/matter_testing_support.py b/src/python_testing/matter_testing_support.py index 9c3ea77534a418..41ca04fa538aa1 100644 --- a/src/python_testing/matter_testing_support.py +++ b/src/python_testing/matter_testing_support.py @@ -2141,7 +2141,7 @@ def matching_runner(self: MatterBaseTest, *args, **kwargs): def run_if_endpoint_matches(accept_function: EndpointCheckFunction): - """ Test decorator for a test that needs to be run only if the endpoint that meets the accept_function criteria. + """ Test decorator for a test that needs to be run only if the endpoint meets the accept_function criteria. Place this decorator above the test_ method to have the test framework run this test only if the endpoint matches. This decorator takes an EndpointCheckFunction to assess whether a test needs to be run on a particular diff --git a/src/python_testing/test_testing/TestDecorators.py b/src/python_testing/test_testing/TestDecorators.py index 4e5ce473b414a2..1ad5bc550bc237 100644 --- a/src/python_testing/test_testing/TestDecorators.py +++ b/src/python_testing/test_testing/TestDecorators.py @@ -32,9 +32,8 @@ from chip.clusters import Attribute try: - from matter_testing_support import (MatterBaseTest, MatterTestConfig, async_test_body, has_attribute, - has_cluster, has_feature, run_if_endpoint_matches, run_on_singleton_matching_endpoint, - should_run_test_on_endpoint) + from matter_testing_support import (MatterBaseTest, MatterTestConfig, async_test_body, has_attribute, has_cluster, has_feature, + run_if_endpoint_matches, run_on_singleton_matching_endpoint, should_run_test_on_endpoint) except ImportError: sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) from matter_testing_support import (MatterBaseTest, MatterTestConfig, async_test_body, has_attribute, @@ -107,9 +106,6 @@ def show_prompt(self, class TestDecorators(MatterBaseTest): - def teardown_test(self): - self.matter_test_config.endpoint = None - def test_checkers(self): has_onoff = has_cluster(Clusters.OnOff) has_onoff_onoff = has_attribute(Clusters.OnOff.Attributes.OnOff) @@ -278,7 +274,7 @@ def run_check(test_name: str, read_response: Attribute.AsyncReadTransaction.Read stopped_ok = hooks.stopped == num_endpoints if not ok or not started_ok or not skipped_ok or not stopped_ok: failures.append( - f'Expected {expected_runs} run of {test_name}, skips expected: {expect_skip}. Runs: {hooks.started}, skips: {hooks.skipped} stops: {hooks.stopped}') + f'Expected {num_endpoints} run of {test_name}, skips expected: {expect_skip}. Runs: {hooks.started}, skips: {hooks.skipped} stops: {hooks.stopped}') def check_once_per_endpoint(test_name: str): run_check(test_name, get_clusters([0, 1]), False) @@ -341,14 +337,14 @@ def run_singleton_dynamic(test_name: str, cluster_list: list[int]) -> tuple[bool return ok, hooks def expect_success_dynamic(test_name: str, cluster_list: list[int]): - ok, hooks = run_singleton_dynamic(test_name, [0]) + ok, hooks = run_singleton_dynamic(test_name, cluster_list) if not ok: failures.append(f"Unexpected failure on {test_name} with cluster list {cluster_list}") if hooks.skipped: failures.append(f'Unexpected skip call on {test_name} with cluster list {cluster_list}') def expect_failure_dynamic(test_name: str, cluster_list: list[int]): - ok = run_singleton_dynamic(test_name, [0]) + ok, hooks = run_singleton_dynamic(test_name, cluster_list) if ok: failures.append(f"Unexpected success on {test_name} with cluster list {cluster_list}") if hooks.skipped: @@ -356,7 +352,7 @@ def expect_failure_dynamic(test_name: str, cluster_list: list[int]): failures.append(f'Skip called for {test_name} with cluster list {cluster_list}') def expect_skip_dynamic(test_name: str, cluster_list: list[int]): - ok = run_singleton_dynamic(test_name, [0]) + ok, hooks = run_singleton_dynamic(test_name, cluster_list) if not ok: failures.append(f"Unexpected failure on {test_name} with cluster list {cluster_list}") if not hooks.skipped: @@ -375,10 +371,10 @@ def expect_skip_dynamic(test_name: str, cluster_list: list[int]): expect_failure_dynamic(test_name, [0, 1]) test_name = 'test_no_run_on_singleton_matching_endpoint' - # no failure, expect skips on single endpoints, expect asserts on multiple matching + # no failure, no matches, expect skips on all endpoints expect_skip_dynamic(test_name, [0]) expect_skip_dynamic(test_name, [1]) - expect_failure_dynamic(test_name, [0, 1]) + expect_skip_dynamic(test_name, [0, 1]) test_runner.Shutdown() print(