Skip to content

Commit 72b1da7

Browse files
authored
python framework: Fix warning on asyncio not awaited (project-chip#36915)
Testing: TC_TestArrtAvail.py
1 parent 4baf343 commit 72b1da7

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -1142,8 +1142,6 @@ def setup_class(self):
11421142
self.current_step_index = 0
11431143
self.step_start_time = datetime.now(timezone.utc)
11441144
self.step_skipped = False
1145-
self.global_wildcard = asyncio.wait_for(self.default_controller.Read(self.dut_node_id, [(Clusters.Descriptor), Attribute.AttributePath(None, None, GlobalAttributeIds.ATTRIBUTE_LIST_ID), Attribute.AttributePath(
1146-
None, None, GlobalAttributeIds.FEATURE_MAP_ID), Attribute.AttributePath(None, None, GlobalAttributeIds.ACCEPTED_COMMAND_LIST_ID)]), timeout=60)
11471145
# self.stored_global_wildcard stores value of self.global_wildcard after first async call.
11481146
# Because setup_class can be called before commissioning, this variable is lazy-initialized
11491147
# where the read is deferred until the first guard function call that requires global attributes.
@@ -1479,6 +1477,13 @@ def pics_guard(self, pics_condition: bool):
14791477
self.mark_current_step_skipped()
14801478
return pics_condition
14811479

1480+
async def _populate_wildcard(self):
1481+
""" Populates self.stored_global_wildcard if not already filled. """
1482+
if self.stored_global_wildcard is None:
1483+
global_wildcard = asyncio.wait_for(self.default_controller.Read(self.dut_node_id, [(Clusters.Descriptor), Attribute.AttributePath(None, None, GlobalAttributeIds.ATTRIBUTE_LIST_ID), Attribute.AttributePath(
1484+
None, None, GlobalAttributeIds.FEATURE_MAP_ID), Attribute.AttributePath(None, None, GlobalAttributeIds.ACCEPTED_COMMAND_LIST_ID)]), timeout=60)
1485+
self.stored_global_wildcard = await global_wildcard
1486+
14821487
async def attribute_guard(self, endpoint: int, attribute: ClusterObjects.ClusterAttributeDescriptor):
14831488
"""Similar to pics_guard above, except checks a condition and if False marks the test step as skipped and
14841489
returns False using attributes against attributes_list, otherwise returns True.
@@ -1492,8 +1497,7 @@ async def attribute_guard(self, endpoint: int, attribute: ClusterObjects.Cluster
14921497
if self.attribute_guard(condition2_needs_to_be_false_to_skip_step):
14931498
# skip step 2 if condition not met
14941499
"""
1495-
if self.stored_global_wildcard is None:
1496-
self.stored_global_wildcard = await self.global_wildcard
1500+
await self._populate_wildcard()
14971501
attr_condition = _has_attribute(wildcard=self.stored_global_wildcard, endpoint=endpoint, attribute=attribute)
14981502
if not attr_condition:
14991503
self.mark_current_step_skipped()
@@ -1512,8 +1516,7 @@ async def command_guard(self, endpoint: int, command: ClusterObjects.ClusterComm
15121516
if self.command_guard(condition2_needs_to_be_false_to_skip_step):
15131517
# skip step 2 if condition not met
15141518
"""
1515-
if self.stored_global_wildcard is None:
1516-
self.stored_global_wildcard = await self.global_wildcard
1519+
await self._populate_wildcard()
15171520
cmd_condition = _has_command(wildcard=self.stored_global_wildcard, endpoint=endpoint, command=command)
15181521
if not cmd_condition:
15191522
self.mark_current_step_skipped()
@@ -1532,8 +1535,7 @@ async def feature_guard(self, endpoint: int, cluster: ClusterObjects.ClusterObje
15321535
if self.feature_guard(condition2_needs_to_be_false_to_skip_step):
15331536
# skip step 2 if condition not met
15341537
"""
1535-
if self.stored_global_wildcard is None:
1536-
self.stored_global_wildcard = await self.global_wildcard
1538+
await self._populate_wildcard()
15371539
feat_condition = _has_feature(wildcard=self.stored_global_wildcard, endpoint=endpoint, cluster=cluster, feature=feature_int)
15381540
if not feat_condition:
15391541
self.mark_current_step_skipped()

0 commit comments

Comments
 (0)