Changes to supported evaluation syntax in Python 3
Initial topic - https://groups.google.com/forum/#!topic/robotframework-users/OX5OvCmVwio
For some reasons expression Evaluate [$PAGE_COMPONENTS[k]['name'] for k in $PAGE_COMPONENTS] doesn't work for python 3.7, but works perfectly for python 2.7
Evaluating expression '[RF_VAR_PAGE_COMPONENTS [k ]['name']for k in RF_VAR_PAGE_COMPONENTS ]' failed: NameError: name 'RF_VAR_PAGE_COMPONENTS' is not defined
*** Settings ***
Documentation Handle nested dicts
Library Collections
*** Variables ***
&{PAGE_COMPONENTS} component_one=&{COMPONENT_ONE_PARAMS}
... component_two=&{COMPONENT_TWO_PARAMS}
&{COMPONENT_ONE_PARAMS} name=ComponentOne parameter=ParameterOne
&{COMPONENT_TWO_PARAMS} name=ComponentTwo parameter=ParameterTwo
@{EXPECTED_NAMES} ComponentOne ComponentTwo
*** Test cases ***
Access To Nested Dict Values In Evaluate Keyword
${robot_version} = Evaluate robot.version.get_full_version(program=None, naked=False) modules=robot
Log ${robot_version} level=WARN
@{component_names} = Evaluate [$PAGE_COMPONENTS[k]['name'] for k in $PAGE_COMPONENTS]
# @{component_names} = Evaluate [${PAGE_COMPONENTS}\[k]['name'] for k in $PAGE_COMPONENTS] - it works for both versions, but I don't have any idea why the previous line doesn't work
Log ${component_names} level=WARN
Lists Should Be Equal ${component_names} ${EXPECTED_NAMES}
*** Keywords ***
d:\rf_bug_report>robot handle_nested_dicts.robot
==============================================================================
Handle Nested Dicts :: Handle nested dicts
==============================================================================
**[ WARN ] 3.1.2 (Python 2.7.13 on win32)**
[ WARN ] [u'ComponentOne', u'ComponentTwo']
Access To Nested Dict Values In Evaluate Keyword | PASS |
------------------------------------------------------------------------------
Handle Nested Dicts :: Handle nested dicts | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
Output: d:\rf_bug_report\output.xml
Log: d:\rf_bug_report\log.html
Report: d:\rf_bug_report\report.html
d:\rf_bug_report>robot3 handle_nested_dicts.robot
==============================================================================
Handle Nested Dicts :: Handle nested dicts
==============================================================================
**[ WARN ] 3.1.2 (Python 3.7.3 on win32)**
Access To Nested Dict Values In Evaluate Keyword | **FAIL** |
Evaluating expression '[RF_VAR_PAGE_COMPONENTS [k ]['name']for k in RF_VAR_PAGE_COMPONENTS ]' failed: NameError: name 'RF_VAR_PAGE_COMPONENTS' is not defined
------------------------------------------------------------------------------
Handle Nested Dicts :: Handle nested dicts | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================
Output: d:\rf_bug_report\output.xml
Log: d:\rf_bug_report\log.html
Report: d:\rf_bug_report\report.html