Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python framework: Fix warning on asyncio not awaited #36915

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading