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 天前
测试学习之——Pytest Day2
服务器·学习·pytest
chao_7892 天前
pytest 实战演练【pytest】
自动化测试·单元测试·自动化·pytest
qq_513728043 天前
为什么选择 pytest 而不是 unittest
pytest
思则变3 天前
[Pytest][Part 5]单条测试和用例集测试
pytest
杨梅树5 天前
pytest中mark的使用
pytest
测试开发技术7 天前
如何在 Pytest 中调用其他用例返回的接口参数?
面试·自动化·pytest·接口·接口测试·api测试
思则变8 天前
[Pytest][Part 4]多种测试运行方式
pytest
程序员三藏8 天前
如何使用Pytest进行测试?
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·pytest
一个处女座的测试10 天前
Python语言+pytest框架+allure报告+log日志+yaml文件+mysql断言实现接口自动化框架
python·mysql·pytest
思则变13 天前
[Pytest][Part 1]Pytest 自动化测试框架
pytest