Convert To Dictionary in Robot Framework gives the error "ValueError: dictionary update sequence element #0 has length 1; 2 is required"

Convert To Dictionary in Robot Framework gives the error "ValueError: dictionary update sequence element #0 has length 1; 2 is required"

我似乎找不到“转换为词典”关键字的任何示例,所以我不太确定如何使用它。

以下代码:

 ${newdomain_dict}                 Convert To Dictionary   {'id': 'newdomain', 'entityTypes': ['users', 'msg', 'xmpp']} 

给出错误“ValueError:字典更新序列元素 #0 的长度为 1;需要 2”

文档只是说这个关键字有一个参数(项目),所以我不确定这个“项目”是什么意思——我假设是一个字符串。即使当我查看 github 源代码时,这也是我得到的印象。

这是因为参数 {'id': 'newdomain', 'entityTypes': ['users', 'msg', 'xmpp']} 被视为字符串。

该关键字的文档是这样说的:

Mainly useful for converting other mappings to normal dictionaries.

字符串不是映射类型。

如果您想通过字符串定义字典,可以使用机器人的 inline python evaluation

${newdomain_dict}  ${{ {'id': 'newdomain', 'entityTypes': ['users', 'msg', 'xmpp']} }}