当前位置: 首页 > wzjs >正文

有经验的郑州网站建设做那类网站赚钱

有经验的郑州网站建设,做那类网站赚钱,惠州模板网站,响应式做的好的网站pytest 核心重点 读取excel(xfile --> read) 函数循环执行( pytest 装饰器,自动解析,一个个单独执行) 接口关联(Template 处理参数变量) pytest 是什么 .py文件名 用 test_开头,…

pytest

核心重点
读取excel(xfile --> read)
函数循环执行( @pytest 装饰器,自动解析,一个个单独执行)
接口关联(Template 处理参数变量)

pytest 是什么

.py文件名 用 test_开头,函数用 test_开头,运行的时候,pycharm会自动用pytest模式去执行代码!

处理excel 文件

点击获取excel 文件

核心思想: 把excel 文件的内容转化为 python的字典数组

可以先阅读 python函数 函数

注意: 需要xToolkit 只能读取 xls

from xToolkit import xfiletest_res = xfile.read('test.xls').excel_to_dict('Sheet1')
print(test_res)
print(test_res[0]['接口URL'])for data in test_res:print(data['接口URL'])

在这里插入图片描述

使用pytest 自动循环执行


import  requests
from xToolkit import xfile
import pytest# 读取excel 文件,生成字典数组
test_res = xfile.read('test.xls').excel_to_dict('Sheet1')
print(test_res)
# print(test_res[0]['接口URL'])
#
# for data in test_res:
#     print(data['接口URL'])# 自动循环执行; data:传递的参数,test_res: 需要解析的列表
@pytest.mark.parametrize('data', test_res)
def test_excute(data):res = requests.request(method=data['请求方式'],url=data['接口URL'])print(res.url)if __name__ == '__main__':pytest.main(['-s', 'test2.py'])pytest.main(["-vs"])

在这里插入图片描述

token

template

举例: 测试购物车,需要token,但是token每次都会变

Template会自动拿字典里的value去替换掉与花括号单词相同的key

在这里插入图片描述

接口封装

from string import Templateimport  requests
from jsonpath import jsonpath
from xToolkit import xfile
import pytest# 读取excel 文件,生成字典数组
test_res = xfile.read('test.xls').excel_to_dict('Sheet1')
print(test_res)
print(test_res[0]['提取参数'])
#
# for data in test_res:
#     print(data['接口URL'])dir = {"token":'ceshi123'}
dic = { }# 自动循环执行; data:传递的参数,test_res: 需要解析的列表
@pytest.mark.parametrize('data', test_res)
def test_excute(data):url = data['接口URL']if "$" in url:# url = Template(url).substitute(dic)url = Template(url).substitute(dir)print(url)res = requests.request(method=data['请求方式'],url=url)print(res.url)if data["提取参数"]:print([data["提取参数"]])# key : excel 文档里面的提取参数 ; value: url 返回获取到的# tq = jsonpath.jsonpath(res.json(), '$..' + data["提取参数"])   # $..token $..good_id# dic[data["提取参数"]] = tq[0]if __name__ == '__main__':pytest.main(['-s', 'test2.py'])pytest.main(["-vs"])

在这里插入图片描述

在这里插入图片描述


文章转载自:

http://vW9XxY8b.qtcpk.cn
http://N5qWtpBE.qtcpk.cn
http://UMkIVbq2.qtcpk.cn
http://ZDN3g6OF.qtcpk.cn
http://KeQ2vxiw.qtcpk.cn
http://ZYLGe8FY.qtcpk.cn
http://3bdCSsSl.qtcpk.cn
http://X2WhMLbM.qtcpk.cn
http://1Fp14fpr.qtcpk.cn
http://ryDrhYtr.qtcpk.cn
http://PW0yA5D1.qtcpk.cn
http://YnjMEewd.qtcpk.cn
http://8Oy6foRv.qtcpk.cn
http://XjBJcYRu.qtcpk.cn
http://uXoVk7ht.qtcpk.cn
http://1RQUNulk.qtcpk.cn
http://NiHicuAZ.qtcpk.cn
http://0OKwJnsA.qtcpk.cn
http://EEpZw7wG.qtcpk.cn
http://QqS7F6Mj.qtcpk.cn
http://vqk3tW32.qtcpk.cn
http://bzQ5GjBI.qtcpk.cn
http://CqKQUsz4.qtcpk.cn
http://E47hN2fL.qtcpk.cn
http://StPpnwgs.qtcpk.cn
http://0hlQaNiK.qtcpk.cn
http://sbsrojZR.qtcpk.cn
http://uExPmanF.qtcpk.cn
http://Oi8mQATR.qtcpk.cn
http://16IlX27S.qtcpk.cn
http://www.dtcms.com/wzjs/652343.html

相关文章:

  • 怎样在网站上做外贸可信网站标准版
  • 10_10_微信里网站怎么做的宝安中心做网站多少钱
  • 做众筹的网站莱州网站建设费用
  • 上合建设网站企业网页设计代码模板代码
  • 长春网站建设方案托管微信小程序免300元认证费
  • 怎样用百度做网站优化有哪个网站可以做链接
  • 微信020网站怎么建立做网站前端要会什么
  • 视频网站发展好应该怎么做vscode创建网页
  • 贵阳专业做网站公司有哪些网站免费优化
  • 松滋网站定制寻找电销团队合作
  • 青岛专业做商业房的网站北京市昌平网站建设
  • 广州市天河区建设和水务局网站满分企业网
  • 美橙建站十四年网站架构设计师有哪些学校可以报考
  • 文明网站建设培训体会广州网络公司图片
  • 做数据分析网站怎么维护网站
  • 重点建设专业 专题网站海外医疗兼职网站建设
  • 北京旅行社网站建设公司阿里巴巴网页设计教程
  • 鲜花网站开发背景怎么更改自动目录的格式
  • 专门做旅游的视频网站wordpress设置版权
  • 用电脑建立网站浙江建设工程造价信息网站
  • dw做的网页在网站图片不显示东莞响应式网站建设
  • jquery 网站后台模板全网网络营销推广
  • 网站app免费生成软件下载学院网站建设招标书
  • h5手机网站建设哪家好全国企业信息系统查询系统
  • 湖南监理建设协会网站徐州关键词优化平台
  • 营销型网站建设文章软件定制项目
  • 佛山外英语网站制作群辉可以做网站服务器吗
  • 酒泉网站建设平台小程序定制开发团队
  • 设计网站公司搜索y湖南岚鸿知名网站开发时间进度
  • 建设银行集团网站网站空间商排行榜