Why "dictionary variable cannot be assigned with other variables"?

446 views
Skip to first unread message

Fabio Pezzoni

unread,
Sep 3, 2015, 8:21:27 AM9/3/15
to robotframework-users
Hi all,

using Robot Framework 2.9 I naturally try to take advantage of the new dictionary variables assigning them along with scalar variables but I get the error: "dictionary variable cannot be assigned with other variables".

I found the following test in the repository so I suppose this behaviour is by design. May I ask the reason of this limitation?

Dictionary only allowed alone 1
    [Documentation]     FAIL Dictionary variable cannot be assigned with other variables.
    ${s}    &{d} =    Fail    Not executed

Thank you,

Fabio

chit bob

unread,
Feb 17, 2016, 1:21:54 AM2/17/16
to robotframework-users
Hi,

I have started playing with RF 2.9, and I am facing this situation as well. The reason could be, as dictionaries are newly introduced in RF 2.9 and designer might have expected the users to use the same returning dictionary to store that scalar variable as well. 

But some times we will face situations where we badly need to return a separate scalar variable. Most likely we should have this resolved in the coming versions. 

Till then we cant do anything except 'ADJUST' ;) 

Regards

Pekka Klärck

unread,
Feb 20, 2016, 4:18:39 PM2/20/16
to chit.c...@gmail.com, robotframework-users
Hello,

While designing how dictionary variables should work, we actually
spent some time thinking how to handle cases where a dictionary
variable is not assigned alone:

&{dict1} &{dict2} = Keyword
${scalar} &{dict} = Keyword
&{dict} ${scalar} = Keyword

We could have decided to make them work, assuming the keyword returns
two items (technically any list-like object with two items), and items
matching dict variables would actually contain a mapping. The reason
we decided not to allow them was that similar cases with list
variables work totally differently:

${scalar} @{list} = Keyword
@{list} ${scalar} = Keyword

The above cases require the keyword to return one or more values
(technically any list-like object with one or more items). The item
matching the scalar variable will be assigned to it, but the remaining
values will be assigned to the list variable. Using a list variable
more than once fails:

@{list1} @{list2} = Keyword

In other words, we were worried that list and dict variables working
totally differently in this case would be confusing. We also thought
that there wouldn't be too much needs to assign dict variables other
than alone. Two emails about this subject on this list clearly shows
that at least some users would like to use the functionality we
decided not to support initially. Luckily changing the logic shouldn't
be too hard and the change shouldn't cause any backwards compatibility
problems. If the general consensus is that the behavior should be
changed, I'd be happy to review and merge pull requests.

Cheers,
.peke
> --
> You received this message because you are subscribed to the Google Groups
> "robotframework-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to robotframework-u...@googlegroups.com.
> To post to this group, send email to robotframe...@googlegroups.com.
> Visit this group at https://groups.google.com/group/robotframework-users.
>
> For more options, visit https://groups.google.com/d/optout.



--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org
Reply all
Reply to author
Forward
0 new messages