22Variables extended_assign_vars.py
33Library Collections
44
5+ *** Variables ***
6+ &{DICT } key=value
7+
58*** Test Cases ***
69Set attributes to Python object
710 [Setup] Should Be Equal ${VAR.attr } -${VAR.attr2 } value-v2
@@ -25,31 +28,47 @@ Set item to list attribute
2528 ${body.data } [${0 } ] = Set Variable firstVal
2629 ${body.data } [-1 ] = Set Variable lastVal
2730 ${body.data } [1 :3] = Create List ${98 } middle ${99 }
28- ${EXPECTED_LIST } = Create List firstVal ${98 } middle ${99 } lastVal
29- Lists Should Be Equal ${body.data } ${EXPECTED_LIST }
31+ Lists Should Be Equal ${body.data } ${{['firstVal', 98, 'middle', 99, 'lastVal'] } }
3032
3133Set item to dict attribute
3234 &{body } = Evaluate {'data': {'key': 'val', 0: 1}}
3335 ${body.data } [key] = Set Variable newVal
3436 ${body.data } [${0 } ] = Set Variable ${2 }
3537 ${body.data } [newKey] = Set Variable newKeyVal
36- ${EXPECTED_DICT } = Create Dictionary key=newVal ${0 } =${2 } newKey=newKeyVal
37- Dictionaries Should Be Equal ${body.data } ${EXPECTED_DICT }
38+ Dictionaries Should Be Equal ${body.data } ${{{'key': 'newVal', 0: 2, 'newKey': 'newKeyVal' } }}
39+
40+ Set using @-syntax
41+ [Documentation] FAIL Setting '\@{VAR.fail}' failed: Expected list-like value, got string.
42+ @{DICT.key } = Create List 1 2 3
43+ Should Be Equal ${DICT } ${{{'key': ['1', '2', '3'] } }}
44+ @{VAR.list: int } = Create List 1 2 3
45+ Should Be Equal ${VAR.list } ${{[ 1 , 2, 3] } }
46+ @{VAR.fail } = Set Variable not a list
47+
48+ Set using &-syntax
49+ [Documentation] FAIL Setting '\&{DICT.fail}' failed: Expected dictionary-like value, got integer.
50+ &{VAR.dict } = Create Dictionary key=value
51+ Should Be Equal ${VAR.dict } ${{{'key': 'value' } }}
52+ Should Be Equal ${VAR.dict.key } value
53+ &{DICT.key: int=float } = Create Dictionary 1=2.3 ${4.0 } =${5.6 }
54+ Should Be Equal ${DICT } ${{{'key': {1: 2.3, 4: 5.6 } }}}
55+ Should Be Equal ${DICT.key } [${1 } ] ${2.3 }
56+ &{DICT.fail } = Set Variable ${666 }
3857
3958Trying to set un-settable attribute
40- [Documentation] FAIL STARTS: Setting attribute 'not_settable' to variable ' \${VAR}' failed: AttributeError:
59+ [Documentation] FAIL STARTS: Setting ' \${VAR.not_settable }' failed: AttributeError:
4160 ${VAR.not_settable } = Set Variable whatever
4261
4362Un-settable attribute error is catchable
4463 [Documentation] FAIL GLOB:
4564 ... Teardown failed:
4665 ... Several failures occurred:
4766 ...
48- ... 1) Setting attribute 'not_settable' to variable ' \${VAR}' failed: AttributeError: *
67+ ... 1) Setting ' \${VAR.not_settable }' failed: AttributeError: *
4968 ...
5069 ... 2) AssertionError
5170 Run Keyword And Expect Error
52- ... Setting attribute 'not_settable' to variable ' \${VAR}' failed: AttributeError: *
71+ ... Setting ' \${VAR.not_settable }' failed: AttributeError: *
5372 ... Setting unsettable attribute
5473 [Teardown] Run Keywords Setting unsettable attribute Fail
5574
@@ -78,11 +97,6 @@ Attribute name must be valid
7897 Should Be Equal ${VAR.2nd } starts with number
7998 Should Be Equal ${VAR.foo-bar } invalid char
8099
81- Extended syntax is ignored with list variables
82- @{list } = Create List 1 2 3
83- @{list.new } = Create List 1 2 3
84- Should Be Equal ${list } ${list.new }
85-
86100*** Keywords ***
87101Extended assignment is disabled
88102 [Arguments] ${value }
0 commit comments