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

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

相关推荐
小卓(friendhan2005)21 小时前
基于 Pytest + Requests + Allure 的博客系统API自动化测试实践
pytest
小卓(friendhan2005)1 天前
基于 Pytest + Selenium + Allure 的博客系统自动化测试实践
selenium·测试工具·pytest
金玉满堂@bj2 天前
Pytest 完整使用教程
运维·服务器·pytest
测试员周周2 天前
【Appium 系列】第10节-手势操作实战 — 滑动、拖拽、缩放与轻拂
linux·服务器·开发语言·人工智能·python·appium·pytest
金玉满堂@bj2 天前
pytest+uiautomation+allure 数据驱动桌面自动化项目搭建指南-yaml版本
运维·自动化·pytest
金玉满堂@bj2 天前
pytest+uiautomation+allure+Excel 数据驱动桌面自动化
自动化·excel·pytest
Be reborn3 天前
用例不是孤立执行的:依赖、变量池与 storage_state 设计
python·自动化·pytest
小陈的进阶之路3 天前
安集商城接口自动化项目架构介绍
python·自动化·pytest
测试员周周3 天前
【Appium 系列】第08节-pytest 集成 — conftest.py 中的 fixture 与 hook
开发语言·人工智能·python·功能测试·appium·测试用例·pytest
Be reborn3 天前
从一行 CSV 到一次浏览器操作:关键字驱动执行引擎设计
python·自动化·pytest