python接口自动化框架搭建_python 搭建接口自动化框架

创建项目:

2019050-20200428190142706-1250616705.png

调试接口函数

根据接口文档,在demo中编写对应接口函数(便于调试函数用的)

import requests

import config

import pprint

url = '{}/api/mgr/sq_mgr/'.format(config.HOST)

param = {"action":"list_course","pagenum":1,"pagesize":20}

r = requests.get(url,params=param)

pprint.pprint(r.json())

配置全局变量

在config.py中配置全局变量

HOST = 'http://10.161.54.84'

formheader = {"Content-Type":"application/x-www-form-urlencoded"}

jsonheader = {"Content-Type":"application/json"}

useranme = 'auto'

password = 'sdfsdfsdf'

lib包下定义函数

包含登录,课程新增/列出/删除,requests请求函数,xls表格处理函数

2019050-20200428191326145-1989787079.png

执行用例

在doReport.py中编写执行用例

from lib import excelmanageLib

from lib import sendRequstLib

if __name__ == '__main__':

oldpath = 'E:\\apiautotest\data\教管系统-测试用例V1.2.xls'

newpath = 'E:\\apiautotest\\report\教管系统-测试用例执行结果V1.2.xls'

xls = excelmanageLib.excel()

totallist = xls.readExcel(oldpath,0)

xls.getNewexcel(oldpath, newpath)

resultlist = []

for smalllist in totallist:

result = sendRequstLib.RequstsTest(smalllist)

resultlist.append(result)

xls.writeResult(newpath, 0, resultlist)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值