requests+pytest+allure接口自动化测试
1.读取文件中的数据
2.requests拿到数据请求接口返回状态码
3.通过断言验证返回状态码和200对比
4.生成allure的测试报告
先从聚合数据里面寻找两个或两个以上的接口填入CSV表格中
文件格式必须以csv结尾
1.读取CSV文件中的数据
import csv #导入csv模块
class Read1(): #创建一个类
def read2(self): #创建一个函数
item = [] #新建一个列表为了方便循环数据
r = csv.reader(open(“xinwendemo.csv”,“r”)) #打开存入接口的csv表格
for i in r: #将数据循环添加到空列表item
item.append(i) #将数据添加
c = item[1:] #创建文件夹的时候有个标题,这一步的操作是为了用切片的方式将标题省略
return c #返回数据
a = Read1()
b=a.read2()
print(b)