Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
文档很少谈论这些,只是 PUT/POST/GET/DELETE 的基本参数,但我有一个伴随 PUT 的分段上传,我该如何测试它?谢谢!
回答我自己的问题:
builder = EnvironBuilder(method='POST', data={'foo': 'this is some text', ... 'file': (StringIO('my file contents'), 'test.txt')})
由于 TestClient 是 EnvironBuilder 的包装器,因此只需使用文件键、值扩展数据字典,然后将文件对象包装为 StringIO。