SeldomQA / seldom

Seldom automation testing framework based on unittest

Home Page:https://seldomqa.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

解析json数据,提示ValueError错误

liuchangfu opened this issue · comments

在解析json数据的时候,运行github上面的demo时,报错了ValueError: Check the test data, no 'name'

Traceback (most recent call last):
File "D:\Python310\lib\site-packages\seldom\testdata\conversion.py", line 111, in json_to_list
data = json.load(f)[key]
KeyError: 'name'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "E:\workspace\seldom-web-testing\test_dir\test_006_file_ddt.py", line 5, in
class FileDataTest(seldom.TestCase):
File "E:\workspace\seldom-web-testing\test_dir\test_006_file_ddt.py", line 13, in FileDataTest
@file_data("json_data.json", key="name")
File "D:\Python310\lib\site-packages\seldom\testdata\parameterization.py", line 158, in file_data
data_list = conversion.json_to_list(file_path, key=key)
File "D:\Python310\lib\site-packages\seldom\testdata\conversion.py", line 114, in json_to_list
raise ValueError("Check the test data, no '{}'".format(key))
ValueError: Check the test data, no 'name'

seldom 不支持 pycharm 右键 运行:

image

看清楚项目的运行方式。

seldom 不支持 pycharm 右键 运行:

image

看清楚项目的运行方式。

问题解决了,在@file_data("../test_data/yaml_data.yaml", key="login")中,加上文件所在路径,可以完美运行