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

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

相关推荐
bjwuzh3 天前
使用pytest实现参数化后,控制台输出的日志是乱码
pytest
2025年一定要上岸4 天前
pytest框架 - 第二集 allure报告
pytest
头疼的程序员5 天前
allure生成测试报告(搭配Pytest、allure-pytest)
测试工具·pytest
文人sec6 天前
接口自动化测试设计思路--设计实战
python·https·单元测试·自动化·pytest
测试开发Kevin7 天前
从投入产出、效率、上手难易度等角度综合对比 pytest 和 unittest 框架
python·pytest
测试开发Kevin10 天前
以pytest_addoption 为例,讲解pytest框架中钩子函数的应用
python·pytest
川石教育15 天前
Pytest中的fixture装饰器详解
python自动化测试·pytest·pytest自动化测试框架·pytest测试框架·pytest单元测试框架
春风又。16 天前
接口自动化——参数化
python·测试工具·自动化·pytest
XTY0018 天前
mac电脑pytest生成测试报告
pytest
程序员的世界你不懂18 天前
pytest-前后置及fixture运用
pytest