Validate that embedded args match custom regexps.
Initial validation is done already when matching keywords, but this
validation makes sure arguments match also if they are given as variables.
Currently, argument not matching only causes a deprecation warning, but
that will be changed to ValueError
in RF 8.0:
#4069
Source code in src/robot/running/arguments/embedded.py
| def validate(self, args: Sequence[Any]):
"""Validate that embedded args match custom regexps.
Initial validation is done already when matching keywords, but this
validation makes sure arguments match also if they are given as variables.
Currently, argument not matching only causes a deprecation warning, but
that will be changed to ``ValueError`` in RF 8.0:
https://github.com/robotframework/robotframework/issues/4069
"""
if not self.custom_patterns:
return
for name, value in zip(self.args, args):
if name in self.custom_patterns and isinstance(value, str):
pattern = self.custom_patterns[name]
if not re.fullmatch(pattern, value):
# TODO: Change to `raise ValueError(...)` in RF 8.0.
context = EXECUTION_CONTEXTS.current
context.warn(f"Embedded argument '{name}' got value {value!r} "
f"that does not match custom pattern {pattern!r}. "
f"The argument is still accepted, but this behavior "
f"will change in Robot Framework 8.0.")
|