import ddt import unittest @ddt.ddt class xx(unittest.TestCase): filepath = "C:\\jodie\maiCai_management\\data\\fmsTestData.xlsx" kk = read_excel(filepath,3) #读取excle文件,返回的是 <class ‘xlrd.sheet.Sheet‘> dataList=[]
#将<class ‘xlrd.sheet.Sheet‘>转为List.
for i in range(1, kk.nrows):
rows = kk.row_values(i) dataList.append(rows) print(dataList) @ddt.data(*dataList) #两层list需要用*解包 @ddt.unpack def test_1(self,parentId,level,name,page,pageSize,expect): print(parentId,level,name,page,pageSize,expect)
yml格式参数化:
import yaml fp = open(‘./config/FMS_parameters.yml‘, encoding=‘utf-8‘) # 有中文字符的话,加编码格式 testdata = yaml.load(fp) t = testdata[‘cookies‘]
输出: {‘user‘: ‘zhuxiaofeng_5039@100.me‘, ‘pass‘: ‘DDmc202032‘}
原文:https://www.cnblogs.com/jodie2019/p/13159385.html