15 path = "testcase.xls"
16 workbook = xlrd.open_workbook(path)
17 table = workbook.sheets()[0]
18 return table
19
20 # 获取 sheet
21
22 @classmethod
23 def get_nrows(cls, table):
24 nrows = table.nrows
25 return nrows
26
27 # 获取行号
28
29 @classmethod
30 def get_id(cls, table, nrows):
31 testid = []
32 for i in range(1, nrows):
33 testid.append(table.cell(i, 0).value)
34 return testid
35
36 @classmethod
37 def get_name(cls, table, nrows):
38 testname = []
39 for i in range(1, nrows):
40 testname.append(table.cell(i, 1).value)
41 return testname
42
43 # 获取用例 name
44
45 @classmethod
46 def get_data(cls, table, nrows):
47 testdata = []
48 for i in range(1, nrows):
49 try :
50 data = json.loads(table.cell(i, 2).value)
51 testdata.append(data)
52 except ValueError:
53 testdata.append(None)
54 return testdata
55
56 # 获取 data 接口参数
57
58 @classmethod
59 def get_url(cls, table, nrows):
60 testurl = []
61 for i in range(1, nrows):
62 testurl.append(table.cell(i, 3).value)
63 return testurl
64
评论0
最新资源