如何在 Robot Framework 中不将每对转换为字符串的情况下创建元组列表
How to create a list of tuples without each pair being converted to string in Robot Framework
我正在尝试创建一个元组列表以在 RF 中进一步阐述,但只能使用 Create List
关键字设法获得一个字符串列表:
*** Test cases ***
Tuple list test
@{tuples_list}= Create List ('1','one') ('2','two') ('3','three')
Log ${tuples_list}
这样每个元组都是一个字符串,正如它在日志中所看到的那样:
["('1','one')", "('2','two')", "('3','three')"]
是否可以创建元组列表而不将每对转换为字符串?
您可以使用机器人的新功能(自 3.2 起)inline python evaluation 功能:
@{tuples_list}= Set variable ${{ [('1', 'one'), ('2', 'two'), ('3', 'three')] }}
-或-
@{foo}= Create list
... ${{ ('1', 'one') }}
... ${{ ('2', 'two') }}
... ${{ ('3', 'three') }}
我正在尝试创建一个元组列表以在 RF 中进一步阐述,但只能使用 Create List
关键字设法获得一个字符串列表:
*** Test cases ***
Tuple list test
@{tuples_list}= Create List ('1','one') ('2','two') ('3','three')
Log ${tuples_list}
这样每个元组都是一个字符串,正如它在日志中所看到的那样:
["('1','one')", "('2','two')", "('3','three')"]
是否可以创建元组列表而不将每对转换为字符串?
您可以使用机器人的新功能(自 3.2 起)inline python evaluation 功能:
@{tuples_list}= Set variable ${{ [('1', 'one'), ('2', 'two'), ('3', 'three')] }}
-或-
@{foo}= Create list
... ${{ ('1', 'one') }}
... ${{ ('2', 'two') }}
... ${{ ('3', 'three') }}