Reputation: 557
Why is the following statement giving syntax error in Robot Framework? Thanks in advance.
@{hidden_routes_1} = Create List 222.2.1.0 12.250.2.2 222.2.2.0
Run Keyword If '@{hidden_routes_1}'=='@{EMPTY}' Log To Console Lists are equal
Evaluating expression ''['222.2.1.0', '12.250.2.2', '222.2.2.0']'=='[]'' failed: SyntaxError: invalid syntax (, line 1)
Upvotes: 0
Views: 420
Reputation: 20067
This syntax:
'@{hidden_routes_1}'=='@{EMPTY}'
reads as "dump the lists as strings, surround them with single quotes and compare. A string representation of a list is:
['222.2.1.0', '12.250.2.2', '222.2.2.0']
- the members are already with single quotes. Thus the one you've put as an opening is closed by the first for the list members - and this produces syntax error expression.
For this particular usage to work, surround them in the evaluated condition with triple quotes - the python way to mark a string as containing newlines and (arbitrary) quotes:
Run Keyword If """@{hidden_routes_1}"""=="""@{EMPTY}""" Log To Console Lists are equal
Or better, use targeted keywords for doing such checks, like Should Be Empty
or Lists Should Be Equal
.
Upvotes: 1