From 5e965ee7f9e326e2dbb0376f9aed614c3ac1a154 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Mon, 13 Feb 2023 21:10:28 +0100 Subject: [PATCH] [matter_yamltests] Stop failing is no definitions is used for matter_yamltests (#25021) --- .../matter_yamltests/parser.py | 55 ++++++++++--------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/scripts/py_matter_yamltests/matter_yamltests/parser.py b/scripts/py_matter_yamltests/matter_yamltests/parser.py index 9a9e640cc33bfd..59fa5ecad9f371 100644 --- a/scripts/py_matter_yamltests/matter_yamltests/parser.py +++ b/scripts/py_matter_yamltests/matter_yamltests/parser.py @@ -253,33 +253,34 @@ def __init__(self, test: dict, config: dict, definitions: SpecDefinitions, pics_ response_mapping = None response_mapping_name = None - if self.is_attribute: - attribute = definitions.get_attribute_by_name( - self.cluster, self.attribute) - if attribute: - attribute_mapping = self._as_mapping(definitions, self.cluster, - attribute.definition.data_type.name) - argument_mapping = attribute_mapping - response_mapping = attribute_mapping - response_mapping_name = attribute.definition.data_type.name - elif self.is_event: - event = definitions.get_event_by_name( - self.cluster, self.event) - if event: - event_mapping = self._as_mapping(definitions, self.cluster, - event.name) - argument_mapping = event_mapping - response_mapping = event_mapping - response_mapping_name = event.name - else: - command = definitions.get_command_by_name( - self.cluster, self.command) - if command: - argument_mapping = self._as_mapping( - definitions, self.cluster, command.input_param) - response_mapping = self._as_mapping( - definitions, self.cluster, command.output_param) - response_mapping_name = command.output_param + if definitions is not None: + if self.is_attribute: + attribute = definitions.get_attribute_by_name( + self.cluster, self.attribute) + if attribute: + attribute_mapping = self._as_mapping(definitions, self.cluster, + attribute.definition.data_type.name) + argument_mapping = attribute_mapping + response_mapping = attribute_mapping + response_mapping_name = attribute.definition.data_type.name + elif self.is_event: + event = definitions.get_event_by_name( + self.cluster, self.event) + if event: + event_mapping = self._as_mapping(definitions, self.cluster, + event.name) + argument_mapping = event_mapping + response_mapping = event_mapping + response_mapping_name = event.name + else: + command = definitions.get_command_by_name( + self.cluster, self.command) + if command: + argument_mapping = self._as_mapping( + definitions, self.cluster, command.input_param) + response_mapping = self._as_mapping( + definitions, self.cluster, command.output_param) + response_mapping_name = command.output_param self.argument_mapping = argument_mapping self.response_mapping = response_mapping