You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

get_excel.py 1.7 KiB

2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # -*- coding: utf-8 -*-
  2. # @Time : 2017/6/4 20:35
  3. # @Author : lileilei
  4. # @File : get_excel.py
  5. import xlrd, os
  6. from Public.log import LOG, logger
  7. @logger('解析测试用例文件')
  8. def datacel(filepath):
  9. try:
  10. file = xlrd.open_workbook(filepath)
  11. print(file)
  12. rslut = file.sheets()[0]
  13. nrows = rslut.nrows
  14. listid = []
  15. listkey = []
  16. listconeent = []
  17. listurl = []
  18. listmethod = []
  19. listassert = []
  20. listname = []
  21. for i in range(1, nrows):
  22. listid.append(rslut.cell(i, 0).value)
  23. listkey.append(rslut.cell(i, 2).value)
  24. listconeent.append(rslut.cell(i, 3).value)
  25. listurl.append(rslut.cell(i, 4).value)
  26. listname.append(rslut.cell(i, 1).value)
  27. listmethod.append((rslut.cell(i, 5).value))
  28. listassert.append((rslut.cell(i, 6).value))
  29. return listid, listkey, listconeent, listurl, listmethod, listassert, listname
  30. except Exception as e:
  31. print(e)
  32. LOG.info('打开测试用例失败,原因是:%s' % e)
  33. return
  34. @logger('生成数据驱动所用数据')
  35. def makedata():
  36. path = os.path.join(os.path.join(os.getcwd(), 'test_case_data'), 'case.xlsx')
  37. listid, listkey, listconeent, listurl, listmethod, listassert, listname = datacel(path)
  38. make_data = []
  39. for i in range(len(listid)):
  40. make_data.append({'url': listurl[i], 'key': listkey[i],
  41. 'coneent': listconeent[i], 'method': listmethod[i],
  42. 'assertconnect': listassert[i],
  43. 'id': listid[i]},
  44. )
  45. i += 1
  46. return make_data

Introduction

生成接口测试报告

No topics

Contributors (2)