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的数据量大怎么处理

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

相关推荐
H_unique13 小时前
博客接口自动化测试--搭建测试环境&库的介绍&安装allure
python·pytest·测试
真智AI14 小时前
MCP+pytest自动重构回归:复刻ARIS循环
重构·pytest
零基础的修炼1 天前
自动化测试---pytest
pytest
鲜于言悠9052 天前
博客系统测试报告
python·功能测试·selenium·jmeter·测试用例·集成测试·pytest
0和1的舞者3 天前
高并发论坛系统:单元测试 + 接口自动化 + 性能测试 + CI/CD 全链路测试报告
java·测试开发·测试工具·jmeter·pytest·测试·测试报告
独断万古他化3 天前
Python+Pytest 搭建博客系统接口自动化测试框架(全用例执行+完整代码)
pytest·接口自动化·测试·allure·requests
王夏奇3 天前
python-pytest学习
python·学习·pytest
独断万古他化4 天前
Python 接口测试之 requests 库核心用法
python·pytest·接口测试·requests
姚青&5 天前
Pytest 测试用例生命周期管理-fixture
测试用例·pytest
姚青&18 天前
PyCharm 配置与界面化运行
pytest