Skip to content

Commit

Permalink
python framework: Fix warning on asyncio not awaited
Browse files Browse the repository at this point in the history
Testing: TC_TestArrtAvail.py
  • Loading branch information
cecille committed Dec 19, 2024
1 parent b880c14 commit 93f889b
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1125,8 +1125,6 @@ def setup_class(self):
self.current_step_index = 0
self.step_start_time = datetime.now(timezone.utc)
self.step_skipped = False
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(
None, None, GlobalAttributeIds.FEATURE_MAP_ID), Attribute.AttributePath(None, None, GlobalAttributeIds.ACCEPTED_COMMAND_LIST_ID)]), timeout=60)
# self.stored_global_wildcard stores value of self.global_wildcard after first async call.
# Because setup_class can be called before commissioning, this variable is lazy-initialized
# where the read is deferred until the first guard function call that requires global attributes.
Expand Down Expand Up @@ -1462,6 +1460,13 @@ def pics_guard(self, pics_condition: bool):
self.mark_current_step_skipped()
return pics_condition

async def _populate_wildcard(self):
""" Populates self.stored_global_wildcard if not already filled. """
if self.stored_global_wildcard is None:
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(
None, None, GlobalAttributeIds.FEATURE_MAP_ID), Attribute.AttributePath(None, None, GlobalAttributeIds.ACCEPTED_COMMAND_LIST_ID)]), timeout=60)
self.stored_global_wildcard = await global_wildcard

async def attribute_guard(self, endpoint: int, attribute: ClusterObjects.ClusterAttributeDescriptor):
"""Similar to pics_guard above, except checks a condition and if False marks the test step as skipped and
returns False using attributes against attributes_list, otherwise returns True.
Expand All @@ -1475,8 +1480,7 @@ async def attribute_guard(self, endpoint: int, attribute: ClusterObjects.Cluster
if self.attribute_guard(condition2_needs_to_be_false_to_skip_step):
# skip step 2 if condition not met
"""
if self.stored_global_wildcard is None:
self.stored_global_wildcard = await self.global_wildcard
await self._populate_wildcard()
attr_condition = _has_attribute(wildcard=self.stored_global_wildcard, endpoint=endpoint, attribute=attribute)
if not attr_condition:
self.mark_current_step_skipped()
Expand All @@ -1495,8 +1499,7 @@ async def command_guard(self, endpoint: int, command: ClusterObjects.ClusterComm
if self.command_guard(condition2_needs_to_be_false_to_skip_step):
# skip step 2 if condition not met
"""
if self.stored_global_wildcard is None:
self.stored_global_wildcard = await self.global_wildcard
await self._populate_wildcard()
cmd_condition = _has_command(wildcard=self.stored_global_wildcard, endpoint=endpoint, command=command)
if not cmd_condition:
self.mark_current_step_skipped()
Expand All @@ -1515,8 +1518,7 @@ async def feature_guard(self, endpoint: int, cluster: ClusterObjects.ClusterObje
if self.feature_guard(condition2_needs_to_be_false_to_skip_step):
# skip step 2 if condition not met
"""
if self.stored_global_wildcard is None:
self.stored_global_wildcard = await self.global_wildcard
await self._populate_wildcard()
feat_condition = _has_feature(wildcard=self.stored_global_wildcard, endpoint=endpoint, cluster=cluster, feature=feature_int)
if not feat_condition:
self.mark_current_step_skipped()
Expand Down

0 comments on commit 93f889b

Please sign in to comment.