diff --git a/scripts/py_matter_yamltests/matter_yamltests/fixes.py b/scripts/py_matter_yamltests/matter_yamltests/fixes.py index c073b923e163c1..d2d4a5fc48ee71 100644 --- a/scripts/py_matter_yamltests/matter_yamltests/fixes.py +++ b/scripts/py_matter_yamltests/matter_yamltests/fixes.py @@ -59,6 +59,10 @@ def convert_yaml_octet_string_to_bytes(s: str) -> bytes: This handles any c-style hex escapes (e.g. \x5a) and hex: prefix ''' + # Step 0: Check if this is already of type bytes + if isinstance(s, bytes): + return s + # Step 1: handle explicit "hex:" prefix if s.startswith('hex:'): return binascii.unhexlify(s[4:]) diff --git a/scripts/py_matter_yamltests/matter_yamltests/parser.py b/scripts/py_matter_yamltests/matter_yamltests/parser.py index 13dc7156dd1f78..5307d9daffd58b 100644 --- a/scripts/py_matter_yamltests/matter_yamltests/parser.py +++ b/scripts/py_matter_yamltests/matter_yamltests/parser.py @@ -246,12 +246,12 @@ def __init__(self, test: dict, config: dict, definitions: SpecDefinitions, pics_ response_mapping = self._as_mapping( definitions, self.cluster, command.output_param) - self._update_with_definition( - self.arguments_with_placeholders, argument_mapping) - self._update_with_definition( - self.response_with_placeholders, response_mapping) + self.argument_mapping = argument_mapping + self.response_mapping = response_mapping + self.update_arguments(self.arguments_with_placeholders) + self.update_response(self.response_with_placeholders) - # This performs a very basic sanity parse time check of constrains. This parsing happens + # This performs a very basic sanity parse time check of constraints. This parsing happens # again inside post processing response since at that time we will have required variables # to substitute in. This parsing check here has value since some test can take a really # long time to run so knowing earlier on that the test step would have failed at parsing @@ -299,6 +299,14 @@ def _as_mapping(self, definitions, cluster_name, target_name): return target_name + def update_arguments(self, arguments_with_placeholders): + self._update_with_definition( + arguments_with_placeholders, self.argument_mapping) + + def update_response(self, response_with_placeholders): + self._update_with_definition( + response_with_placeholders, self.response_mapping) + def _update_with_definition(self, container: dict, mapping_type): if not container or not mapping_type: return @@ -387,6 +395,8 @@ def __init__(self, test: _TestStepWithPlaceholders, runtime_config_variable_stor self.response = copy.deepcopy(test.response_with_placeholders) self._update_placeholder_values(self.arguments) self._update_placeholder_values(self.response) + test.update_arguments(self.arguments) + test.update_response(self.response) @property def is_enabled(self):