使用json.loads替换eval()来序列化读取的数据内容,excel中填写dict数据时,请尽量手动输入,直接复制可能出现json虚拟化错误,json.loads序列化不支持单引号,可自行尝试eval()函数进行序列化

This commit is contained in:
zy7y 2020-08-09 21:03:39 +08:00
parent 4f7d594872
commit 5dde20a3ff
2 changed files with 1 additions and 1 deletions

Binary file not shown.

View File

@ -147,7 +147,7 @@ class TestApiAuto(object):
with allure.step("根据配置文件的提取响应规则提取实际数据"):
really = jsonpath.jsonpath(res, res_reg)[0]
with allure.step("处理读取出来的预期结果响应"):
expect = eval(expect)
expect = json.loads(expect)
with allure.step("预期结果与实际响应进行断言操作"):
assert really == expect
logger.info(f'完整的json响应: {res}\n 需要校验的数据字典: {really}\n 预期校验的数据字典: {expect}\n 测试结果: {really == expect}\n')