pytest之统一接口请求封装

pytest之统一接口请求封装

pytest的requests_util.py

requests_util.py

python 复制代码
import requests


class RequestsUtil:
    # 创建一个 requests.Session 对象,用于发送 HTTP 请求
    session = requests.session()

    def send_request(self, method, url, data=None, **kwargs):
        # 将请求方法转换为小写字符串
        method = str(method).lower()
        # 定义一个空字符串 res
        res = ""

        # 根据请求方法,选择合适的发送方式
        if method == "get":
            # 使用 GET 方法发送请求
            res = self.session.request(method, url, params=data, **kwargs)
        elif method == "post":
            # 使用 POST 方法发送请求
            res = self.session.request(method, url, json=data, **kwargs)

        # 返回响应
        return res

接口自动化测试框架的封装

yaml文件如何实现接口关联封装

yaml文件如何实现动态参数的处理

yaml文件如何实现文件上传

有参数化时候,怎么实现断言

yaml的数据量大怎么处理

接口自动化框架的扩展:加密接口,签名接口,自定义的功能接口

相关推荐
Lightning-py1 天前
pytest 软断言的几种方式
pytest
Lightning-py1 天前
pytest后置处理方式
pytest
爆更小哇3 天前
Python自动化测试:pytest新手快速入门指南
python·测试工具·自动化·pytest
qq_452396233 天前
第一篇:基座选型 —— 为什么 Pytest 是自动化的终点?
自动化·pytest
时光不写代码4 天前
修复 pytest-asyncio 事件循环冲突:完整解决方案
python·pytest·fastapi
上天_去_做颗惺星 EVE_BLUE4 天前
接口自动化测试全流程:pytest 用例收集、并行执行、Allure 报告合并与上传
python·pytest
踏着七彩祥云的小丑4 天前
pytest——Mark标记
开发语言·python·pytest
lifewange5 天前
pytest-类中测试方法、多文件批量执行
开发语言·python·pytest
我的xiaodoujiao8 天前
API 接口自动化测试详细图文教程学习系列9--Requests模块
python·学习·测试工具·pytest
我的xiaodoujiao8 天前
API 接口自动化测试详细图文教程学习系列10--Requests模块2--举例说明
python·学习·测试工具·pytest