0
点赞
收藏
分享

微信扫一扫

httprunner 4.x学习 - 13. upload 文件上传

前言

requests 库里面上传文件会用到 requests_toolbelt, 可以很方便的解决 multipart/form-data 类型的文件上传相关接口。
HttpRunner4.x 集成了 requests_toolbelt,可以使用内置 upload 关键字来上传文件相关操作。

环境准备

需额外安装2个依赖包

pip install requests-toolbelt filetype

upload 上传文件

在项目根目录新建data目录,放需要传的文件

httprunner 4.x学习 - 13. upload 文件上传_根目录

新建 test_up.yml



config:
    name: file
teststeps:
-
    name: upload file
    request:
        url: http://124.70.221.221:8201/api/v1/upfile/
        method: POST
        upload:
            file: data/yoyo.jpg
            title: xxx
    validate:
        - eq: [body.code, 0]

使用 hrun 目录没问题

hrun test_up.yml

最新4.3.0 版本使用hrp run 无法上传成功

hrp run test_up.yml



举报

相关推荐

0 条评论