【发布时间】:2021-08-23 08:40:34
【问题描述】:
我在 json 中为我的测试功能编写了一个配置文件。配置文件如下所示:
{
"Chrome_executable_path": "C:\\Users\\AIGHOSH\\PycharmProjects\\chromedriver.exe",
"File_locations": [["C:\\Users\\AIGHOSH\\Desktop\\DQ_DATA\\DimenLookupAge8277.csv"],
["C:\\Users\\AIGHOSH\\Desktop\\DQ_DATA\\DimenLookupAge8277.csv", "C:\\Users\\AIGHOSH\\Desktop\\DQ_DATA\\DimenLookupArea8277.csv"],
["C:\\Users\\AIGHOSH\\Desktop\\DQ_DATA\\DimenLookupAge8277.csv", "C:\\Users\\AIGHOSH\\Desktop\\DQ_DATA\\DimenLookupArea8277.csv", "C:\\Users\\AIGHOSH\\Desktop\\DQ_DATA\\DimenLookupEthnic8277.csv"],
["C:\\Users\\AIGHOSH\\Desktop\\DQ_DATA\\DimenLookupAge8277.csv", "C:\\Users\\AIGHOSH\\Desktop\\DQ_DATA\\DimenLookupArea8277.csv", "C:\\Users\\AIGHOSH\\Desktop\\DQ_DATA\\DimenLookupEthnic8277.csv", "C:\\Users\\AIGHOSH\\Desktop\\DQ_DATA\\DimenLookupSex8277.csv"],
["C:\\Users\\AIGHOSH\\Desktop\\DQ_DATA\\DimenLookupAge8277.csv", "C:\\Users\\AIGHOSH\\Desktop\\DQ_DATA\\DimenLookupArea8277.csv", "C:\\Users\\AIGHOSH\\Desktop\\DQ_DATA\\DimenLookupEthnic8277.csv", "C:\\Users\\AIGHOSH\\Desktop\\DQ_DATA\\DimenLookupSex8277.csv", "C:\\Users\\AIGHOSH\\Desktop\\DQ_DATA\\DimenLookupYear8277.csv"]
],
"Null_values": [["_"], ["@"], ["<>"], ["-"], ["#"]],
"Operation": [["None"], ["Append"], ["Merge"], ["Append then Merge"]],
"weights": [
{
"completeness": "0.2",
"timeliness": "0.2",
"uniqueness": "0.2",
"validity": "0.2",
"integrity": "0.2"
},
{
"completeness": "0.1",
"timeliness": "0.3",
"uniqueness": "0.2",
"validity": "0.2",
"integrity": "0.2"
},
{
"completeness": "0.2",
"timeliness": "0.2",
"uniqueness": "0.3",
"validity": "0.1",
"integrity": "0.2"
},
{
"completeness": "0.2",
"timeliness": "0.2",
"uniqueness": "0.1",
"validity": "0.4",
"integrity": "0.1"
},
{
"completeness": "0.1",
"timeliness": "0.1",
"uniqueness": "0.4",
"validity": "0.2",
"integrity": "0.2"
}
]
}
现在我希望 value[0] 成为我的第一个测试用例参数,然后 v[1] 成为我的第二个测试用例参数。
我的测试用例函数:
#for the fist element of the values(eg: v[0])
def test_case(self):
self.dqopenPage = DqOpenPage(self.driver)
self.dqopenPage.drop(filess = config["File_locations"]) #should take the first list with only 1 file
self.dqopenPage.df_operation(operation=config["Operations"]) #should take the "None"
self.dqopenPage.define_null_value(null = config["Null_values"])#should take "_"
那么如何使用 for 循环获取值并为所有对应的值(如 v[1]、v[2] 等)运行测试用例函数。
【问题讨论】:
-
您要测试所有 index-0 元素,然后是所有 index-1,... 还是使用任何索引组合?
-
对我来说,你想做什么还不是很清楚? v[1] 实际上应该是什么?我认为您的代码实际上不需要 DqOpenPage 的东西,那是一个库吗?
-
@gimix 是的! : 测试所有 index-0 元素,然后是所有 index-1,...
标签: python json dictionary nested-lists