Skip to content

Commit

Permalink
Parsing: Build FOR loops always with valid flavor.
Browse files Browse the repository at this point in the history
This avoid issues, at least with string representation used in the log
file, if the flavor is `None`. Alternatively could handle `None` in
the model object, but them we kind of should handle also other invalid
flavors. There's also already typing using `Literal` that specifies
what are the valid values.

Fixes #5120.
  • Loading branch information
pekkaklarck committed Apr 26, 2024
1 parent 1b5143c commit dcf0f91
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion atest/robot/running/for/for.robot
@@ -1,5 +1,6 @@
*** Settings ***
Suite Setup Run Tests ${EMPTY} running/for/for.robot
Suite Setup Run Tests --log log-tests-also-string-reprs.html running/for/for.robot
Suite Teardown File Should Exist ${OUTDIR}/log-tests-also-string-reprs.html
Resource for.resource

*** Test Cases ***
Expand Down
6 changes: 3 additions & 3 deletions src/robot/running/builder/transformers.py
Expand Up @@ -370,9 +370,9 @@ def __init__(self, parent: 'TestCase|UserKeyword|For|If|Try|While'):

def build(self, node):
error = format_error(self._get_errors(node))
self.model.config(assign=node.assign, flavor=node.flavor, values=node.values,
start=node.start, mode=node.mode, fill=node.fill,
lineno=node.lineno, error=error)
self.model.config(assign=node.assign, flavor=node.flavor or 'IN',
values=node.values, start=node.start, mode=node.mode,
fill=node.fill, lineno=node.lineno, error=error)
for step in node.body:
self.visit(step)
return self.model
Expand Down

0 comments on commit dcf0f91

Please sign in to comment.