如何在Robot框架中创建一个元组列表,而不将每个元组对转换为字符串



我试图创建一个元组列表,以便在RF中进一步详细说明,但只管理使用Create List关键字的字符串列表:

*** Test cases ***
Tuple list test
@{tuples_list}=     Create List             ('1','one')     ('2','two')     ('3','three')
Log     ${tuples_list}

这样,每个元组都是一个字符串,就像在日志中看到的那样:

["(' 1 ',' 1 ')"、"(' 2 ',' 2 ')"、"(' 3 ',' 3 ')")

是否有可能创建一个元组列表,而不将每个对转换为字符串?

你可以使用robot的新的(从3.2开始)内联python求值特性:

@{tuples_list}=  Set variable  ${{ [('1', 'one'), ('2', 'two'), ('3', 'three')] }}

或者

@{foo}=  Create list
...  ${{ ('1', 'one') }}
...  ${{ ('2', 'two') }}
...  ${{ ('3', 'three') }}

最新更新