在我的Tavern测试文件中,我保存一个变量,如下所示:
[...]
save:
headers:
csrf: x-csrf-token
[...]当我运行pytest时,它记录了这个警告:
tavern/util/dict_util.py:119: FutureWarning: In a future version of Tavern, selecting for values to save in nested objects will have to be done as a JMES path query - see http://jmespath.org/ for more informationJMESPath.org没有多大帮助,Tavern's documentation也是如此。'x-csrf-token‘字段没有嵌套在'headers’中,所以我不理解这个警告。我尝试了两种不同的类似JMES的语法,但都给出了"cant find key“错误:
save:
csrf: headers.x-csrf-token
save:
headers:
csrf: headers.x-csrf-token酒馆到底在期待什么?
发布于 2020-04-17 21:03:44
JMESPath不带引号的标识符不能包含连字符。您可以改用quoted identifier。尝试:
save:
headers:
csrf: '"x-csrf-token"'单引号是用来告诉YAML双引号是字符串的一部分。JMESPath中的双引号允许您在标识符中包含原本允许的字符,例如连字符。
https://stackoverflow.com/questions/58997357
复制相似问题