Skip to content

Commit f5b5c09

Browse files
committed
Merge remote-tracking branch 'origin/per_node_endpoint_fixes' into per_node_endpoint_fixes
2 parents c01bb23 + c7851b6 commit f5b5c09

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

src/python_testing/TC_TIMESYNC_2_1.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232

3333
import chip.clusters as Clusters
3434
from chip.clusters.Types import NullValue
35-
from matter_testing_support import (MatterBaseTest, default_matter_test_main, has_attribute, has_cluster,
36-
run_if_endpoint_matches, utc_time_in_matter_epoch)
35+
from matter_testing_support import (MatterBaseTest, default_matter_test_main, has_attribute, has_cluster, run_if_endpoint_matches,
36+
utc_time_in_matter_epoch)
3737
from mobly import asserts
3838

3939

src/python_testing/matter_testing_support.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2141,7 +2141,7 @@ def matching_runner(self: MatterBaseTest, *args, **kwargs):
21412141

21422142

21432143
def run_if_endpoint_matches(accept_function: EndpointCheckFunction):
2144-
""" Test decorator for a test that needs to be run only if the endpoint that meets the accept_function criteria.
2144+
""" Test decorator for a test that needs to be run only if the endpoint meets the accept_function criteria.
21452145
21462146
Place this decorator above the test_ method to have the test framework run this test only if the endpoint matches.
21472147
This decorator takes an EndpointCheckFunction to assess whether a test needs to be run on a particular

src/python_testing/test_testing/TestDecorators.py

+8-12
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@
3232
from chip.clusters import Attribute
3333

3434
try:
35-
from matter_testing_support import (MatterBaseTest, MatterTestConfig, async_test_body, has_attribute,
36-
has_cluster, has_feature, run_if_endpoint_matches, run_on_singleton_matching_endpoint,
37-
should_run_test_on_endpoint)
35+
from matter_testing_support import (MatterBaseTest, MatterTestConfig, async_test_body, has_attribute, has_cluster, has_feature,
36+
run_if_endpoint_matches, run_on_singleton_matching_endpoint, should_run_test_on_endpoint)
3837
except ImportError:
3938
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
4039
from matter_testing_support import (MatterBaseTest, MatterTestConfig, async_test_body, has_attribute,
@@ -107,9 +106,6 @@ def show_prompt(self,
107106

108107

109108
class TestDecorators(MatterBaseTest):
110-
def teardown_test(self):
111-
self.matter_test_config.endpoint = None
112-
113109
def test_checkers(self):
114110
has_onoff = has_cluster(Clusters.OnOff)
115111
has_onoff_onoff = has_attribute(Clusters.OnOff.Attributes.OnOff)
@@ -278,7 +274,7 @@ def run_check(test_name: str, read_response: Attribute.AsyncReadTransaction.Read
278274
stopped_ok = hooks.stopped == num_endpoints
279275
if not ok or not started_ok or not skipped_ok or not stopped_ok:
280276
failures.append(
281-
f'Expected {expected_runs} run of {test_name}, skips expected: {expect_skip}. Runs: {hooks.started}, skips: {hooks.skipped} stops: {hooks.stopped}')
277+
f'Expected {num_endpoints} run of {test_name}, skips expected: {expect_skip}. Runs: {hooks.started}, skips: {hooks.skipped} stops: {hooks.stopped}')
282278

283279
def check_once_per_endpoint(test_name: str):
284280
run_check(test_name, get_clusters([0, 1]), False)
@@ -341,22 +337,22 @@ def run_singleton_dynamic(test_name: str, cluster_list: list[int]) -> tuple[bool
341337
return ok, hooks
342338

343339
def expect_success_dynamic(test_name: str, cluster_list: list[int]):
344-
ok, hooks = run_singleton_dynamic(test_name, [0])
340+
ok, hooks = run_singleton_dynamic(test_name, cluster_list)
345341
if not ok:
346342
failures.append(f"Unexpected failure on {test_name} with cluster list {cluster_list}")
347343
if hooks.skipped:
348344
failures.append(f'Unexpected skip call on {test_name} with cluster list {cluster_list}')
349345

350346
def expect_failure_dynamic(test_name: str, cluster_list: list[int]):
351-
ok = run_singleton_dynamic(test_name, [0])
347+
ok, hooks = run_singleton_dynamic(test_name, cluster_list)
352348
if ok:
353349
failures.append(f"Unexpected success on {test_name} with cluster list {cluster_list}")
354350
if hooks.skipped:
355351
# We don't expect a skip call because the test actually failed.
356352
failures.append(f'Skip called for {test_name} with cluster list {cluster_list}')
357353

358354
def expect_skip_dynamic(test_name: str, cluster_list: list[int]):
359-
ok = run_singleton_dynamic(test_name, [0])
355+
ok, hooks = run_singleton_dynamic(test_name, cluster_list)
360356
if not ok:
361357
failures.append(f"Unexpected failure on {test_name} with cluster list {cluster_list}")
362358
if not hooks.skipped:
@@ -375,10 +371,10 @@ def expect_skip_dynamic(test_name: str, cluster_list: list[int]):
375371
expect_failure_dynamic(test_name, [0, 1])
376372

377373
test_name = 'test_no_run_on_singleton_matching_endpoint'
378-
# no failure, expect skips on single endpoints, expect asserts on multiple matching
374+
# no failure, no matches, expect skips on all endpoints
379375
expect_skip_dynamic(test_name, [0])
380376
expect_skip_dynamic(test_name, [1])
381-
expect_failure_dynamic(test_name, [0, 1])
377+
expect_skip_dynamic(test_name, [0, 1])
382378

383379
test_runner.Shutdown()
384380
print(

0 commit comments

Comments
 (0)