# ==========================
# @time:2019/11/17 11:03
# @Author:coco
# @File:handle_request.py
# @software:PyCharm
# ============================
import json
import requests
class HandleRequest:
"""
处理请求
"""
def __init__(self):
# 创建Session会话对象
self.one_session = requests.Session
def add_headers(self, headers):
"""
添加公共请求头
:param headers: 需要添加的请求头, 为字典类型
:return:
"""
# Session会话对象中的headers类似于一个字典
# 可以将待添加的请求头字典与self.one_session.headers中的请求头(类似字典)进行合并覆盖
self.one_session.headers.update(headers)
def send(self, url, method='post', data=None, is_json=
day21:接口测试实战(handle_request.py)
最新推荐文章于 2023-04-16 21:06:33 发布