我需要使用 pyresttest 测试多部分/表单数据的 API。我已经为我的 API 尝试了https://github.com/svanoort/pyresttest/issues/158但它不起作用。
我创建了formdata.txt
:
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="data"; filename="/D:/File-Upload/movie.json"
Content-Type: application/json
(data)
----WebKitFormBoundary7MA4YWxkTrZu0gW
我的 yaml 文件看起来像:
- test:
- group: "Group test"
- name: "Test name"
- url: "/post_movie/"
- method: "POST"
- headers: {'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW'}
- body: {'file':'D:/File-Upload/formdata.txt'}
- expected_status: [200]
但我收到错误:
UnicodeDecodeError: 'unicodeescape' codec can't decode bytes in position 156-157: truncated\UXXXXXXXX escape
如何在 pyresttest 中测试 multipart/form-data ?