HttpRunner httprunner 怎么测试上传图片的接口?

null · 2019年05月16日 · 最后由 null 回复于 2019年06月21日 · 1926 次阅读

RT

共收到 4 条回复 时间 点赞
name: 
request:
    files: 
        file: ['xxx.jpg',$file,'image/jpeg']
    method: POST
2楼 已删除
JKzhishui 回复

麻烦问下,运行接口提示文件参数,参数错误,,我格式设置哪有问题呢

格式设置

得到的请求参数:
'request': {
'url': 'https://XXXXXXXX/lyy/rest/group/distributor/saveMaterial',
'method': 'POST',
'verify': False,
'headers': {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'Cookie': 'SESSION=62d8504a-fa89-49da-b506-bac396937cba; Path=/lyy/; HttpOnly'},
'data': {'name': 'ttr', 'price': 3, 'id': '', 'materialType': '1000020', 'description': 'dddd'},
'files': {'imageUrl': ['7.jpg', 'D:\PGRunner\PGRunner\static\images\7.jpg']}
}

我那个是在 httprunner 里面的 yml 文件运行的。如果你要在 IDE 的话,尝试requests-toolbelt
文档:https://toolbelt.readthedocs.io/en/latest/user.html#multipart-form-data-encoder

null #5 · 2019年06月21日 Author
JKzhishui 回复

$file 是什么。

需要 登录 後方可回應,如果你還沒有帳號按這裡 注册