2014/1/17 David Smith <
dsm...@mypchelp.com>:
> Is this really the expected behavior?
>
> | | @{port_status}= | Run Keyword Unless | '${testname}'=='wan' | SSH Port
> Status Network Interface | ${connection_name} | ${port} |
> | | @{port_status}= | Run Keyword If | '${testname}'=='wan' | SSH Port
> Status Wan Interface | ${connection_name} | ${port} |
>
> if the first line runs, port_status gets a value.
> eventhough the second line case shouldn't run, @{port_status} gets
> overwritten to empty set.
The reason this happens is that all keywords, including Run Keyword If
and Run Keyword Unless, always return value. If there is no other
return value, the return value will be Python None. When assigning to
a list variable, None is later automatically turned into an empty
list.
In cases like the above keywords always returning something is
annoying and we wanted to fix it. Instead of making Run Keyword If and
friends somehow special regarding to how variables are assigned, we
decided to add ELSE IF/ELSE support for Run Keyword If. As Kevin
already demonstrated, this syntax avoids the problem when assigning
variables, and it is clearer than Run Keyword If/Unless combination in
some other use cases too.
Cheers,
.peke
--
Agile Tester/Developer/Consultant ::
http://eliga.fi
Lead Developer of Robot Framework ::
http://robotframework.org