Skip to content

Dictionary variable type #1450

Closed
Closed

Description

@spooning

Originally submitted to Google Code by deville.moodys on 31 May 2013

It'd like to provide dictionaries (key/value) parameters to several functions of my librairies.
Consequently I'd like to have the possibility to create variables of type "dictionary".
I know it is possible to create such variables in a test case, but it could be more "user-friendly" if we could create them as currently scalar and list variables.
Thanks for your reply
Cheers

Activity

  1. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 16 Jun 2013

    Have you tried Create Dictionary in CollectionsLibrary? If you need lot of dictionaries, you could consider using variable files.

  2. added this to the 2.9 milestone on Jun 29, 2014
  3. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by deville.moodys on 17 Jun 2013

    Hi, I have indeed tried "Create Dictionary" and that is what I refeered in my request.
    However, as my dictionary variable will contain a "fixed value", I'd rather setting it like scalar and list variables. Setting it at runtime is not so clear for anybody that will have a look at the test. Don't you share this point of view ?
    Cheers

  4. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 1 Nov 2013

    I didn't understand your initial description correctly. Yes, it would be handy if there was a separate variable type for dictionaries like we have @⁠{var} for lists. Being able to create them in the variable table would be convenient, but most importantly they could be used when passing named arguments to keywords. That is required by issue 1561.

    This new variable type should work so that they can be created in the variable table like:

    *** Variables ***
    &{EXAMPLE}    key=value    key2=another value
    

    Then it should be possible to use them in the test data as scalar variables like:

    Should Contain    ${EXAMPLE}    key    # First argument is a dictionary
    

    Using them in &{name} format would mean unpacking the dictionary and passing individual arguments to a keyword as named arguments. Following two keyword calls should be identical:

    My Keyword    &{EXAMPLE}
    My Keyword    key=value    key2=another value
    
  5. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 1 Nov 2013

    Issue 1385 has been merged into this issue.

  6. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by jtbnnt on 7 Mar 2014

    It would also be nice to be able index the dictionary variable in the same way a list variable can be indexed.

    E.g.:

    Log &{EXAMPLE}["key"]

  7. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by jtbnnt on 30 Apr 2014

    I'm assuming this would also cover the case of having kwargs passed into user keywords?

    E.g.:

    *** Keywords ***
    This Keyword Takes KWArgs
        [Arguments]    &{args}
        Log    &{args}[my_arg]
    
    *** Test Cases ***
    Test
       This Keyword Takes KWArgs    my_arg=Hello World

    Output:

    Log: "Hello World!"


    Comment by @pekkaklarck: This is part of separate but highly related issue #1561.

  8. added a commit that references this issue on Feb 6, 2015
  9. self-assigned this
    on Feb 8, 2015
  10. pekkaklarck commented on Feb 8, 2015

    @pekkaklarck
    Member

    Forgot to mention this issue in few commits.

    • 681c65e added logging dict variable assignment and dict variable recommendations.
    • 3da0db9 implemented support for accessing dict values like &{dict}[key].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions