2017-06-04 20:52:17 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
# @Time : 2017/6/4 20:35
|
|
|
|
|
# @Author : lileilei
|
|
|
|
|
# @File : get_excel.py
|
|
|
|
|
# @Software: PyCharm
|
2018-03-13 13:17:23 +08:00
|
|
|
import xlrd
|
2017-10-31 21:20:00 +08:00
|
|
|
from Public.log import LOG,logger
|
2017-10-16 21:00:09 +08:00
|
|
|
@logger('解析测试用例文件')
|
2017-06-04 20:52:17 +08:00
|
|
|
def datacel():
|
2017-10-16 21:00:09 +08:00
|
|
|
try:
|
2017-10-28 14:45:27 +08:00
|
|
|
filepath='.\\test_case\\case.xlsx'
|
2017-10-16 21:00:09 +08:00
|
|
|
file=xlrd.open_workbook(filepath)
|
|
|
|
|
me=file.sheets()[0]
|
|
|
|
|
nrows=me.nrows
|
|
|
|
|
listid=[]
|
|
|
|
|
listkey=[]
|
|
|
|
|
listconeent=[]
|
|
|
|
|
listurl=[]
|
|
|
|
|
listfangshi=[]
|
|
|
|
|
listqiwang=[]
|
|
|
|
|
listrelut=[]
|
|
|
|
|
listname=[]
|
|
|
|
|
for i in range(1,nrows):
|
|
|
|
|
listid.append(me.cell(i,0).value)
|
|
|
|
|
listkey.append(me.cell(i,2).value)
|
|
|
|
|
listconeent.append(me.cell(i,3).value)
|
|
|
|
|
listurl.append(me.cell(i,4).value)
|
|
|
|
|
listname.append(me.cell(i,1).value)
|
|
|
|
|
listfangshi.append((me.cell(i,5).value))
|
|
|
|
|
listqiwang.append((me.cell(i,6).value))
|
|
|
|
|
return listid,listkey,listconeent,listurl,listfangshi,listqiwang,listname
|
2017-10-31 21:20:00 +08:00
|
|
|
except:LOG.info('打开测试用例失败,原因是:%s'%Exception)
|
|
|
|
|
@logger('生成数据驱动所用数据')
|
|
|
|
|
def makedata():
|
|
|
|
|
listid, listkey, listconeent, listurl, listfangshi, listqiwang, listname=datacel()
|
|
|
|
|
make_data=[]
|
|
|
|
|
for i in range(len(listid)):
|
|
|
|
|
make_data.append({'url':listurl[i],'key':listkey[i],'coneent':listconeent[i],'fangshi':listfangshi[i],'qiwang':listqiwang[i]})
|
|
|
|
|
i+=1
|
2018-03-12 21:00:36 +08:00
|
|
|
return make_data
|