Skip to content

Commit 2c2f21a

Browse files
committed
Fine tune fix for handling broken assign (#4118)
- Add acceptance tests. - Avoid overly long line.
1 parent dc5250e commit 2c2f21a

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

atest/robot/variables/return_values.robot

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,12 @@ Invalid count error is catchable
212212

213213
Invalid type error is catchable
214214
Check Test Case ${TESTNAME}
215+
216+
Invalid assign
217+
Check Test Case ${TESTNAME}
218+
219+
Invalid assign with assign mark
220+
Check Test Case ${TESTNAME}
221+
222+
Too many assign marks
223+
Check Test Case ${TESTNAME}

atest/testdata/variables/return_values.robot

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,18 @@ Invalid type error is catchable
334334
... Assign dict variable not dict AND
335335
... Fail Also this is executed!
336336

337+
Invalid assign
338+
[Documentation] FAIL No keyword with name '\${oops' found.
339+
${oops Set Variable whatever
340+
341+
Invalid assign with assign mark
342+
[Documentation] FAIL No keyword with name '\${oops=' found.
343+
${oops= Set Variable whatever
344+
345+
Too many assign marks
346+
[Documentation] FAIL No keyword with name '\${oops}==' found.
347+
${oops}== Set Variable whatever
348+
337349
*** Keywords ***
338350
Assign multiple variables
339351
[Arguments] @{args}

src/robot/variables/search.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ def is_dict_variable(self):
124124

125125
def is_assign(self, allow_assign_mark=False):
126126
if allow_assign_mark and self.string.endswith('='):
127-
return search_variable(rstrip(self.string[:-1]), ignore_errors=True).is_assign()
127+
match = search_variable(rstrip(self.string[:-1]), ignore_errors=True)
128+
return match.is_assign()
128129
return (self.is_variable()
129130
and self.identifier in '$@&'
130131
and not self.items

0 commit comments

Comments
 (0)