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

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

相关推荐
西游音月2 天前
(2)pytest+Selenium自动化测试-环境准备
selenium·测试工具·pytest
我的xiaodoujiao2 天前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 23--数据驱动--参数化处理 Yaml 文件
python·学习·测试工具·pytest
我的xiaodoujiao5 天前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 22--数据驱动--参数化处理 Json 文件
python·学习·测试工具·pytest
胜天半月子6 天前
Python自动化测试 | 快速认识并了解pytest的基本使用
服务器·python·pytest
北珣.10 天前
自动化框架pytest基础
自动化·pytest
程序员杰哥11 天前
Pytest之收集用例规则与运行指定用例
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·pytest
学习3人组11 天前
Python + requests + pytest + allure + Jenkins 构建完整的接口自动化测试框架
python·jenkins·pytest
shao91851614 天前
Gradio全解14——使用Gradio构建MCP的服务器与客户端(4)——Python包命令:uv与uvx实战
pytest·uv·1024程序员节·npx·uvx·uv pip·ruff
我的xiaodoujiao15 天前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 20--PO(POM) 设计模式和用例撰写
python·学习·测试工具·设计模式·pytest
sky0Lan16 天前
一个类似 pytest 的 html 报告
android·html·pytest