3
如何测试将文件上传作为POST参数的Pylons控制器(使用鼻测试)?鼻子测试 - 文件上传
如何测试将文件上传作为POST参数的Pylons控制器(使用鼻测试)?鼻子测试 - 文件上传
像这样:
class TestUploadController(TestController):
// ....
def test_upload_files(self):
""" Check that upload of text file works. """
files = [("Filedata", "filename.txt", "contents of the file")]
res = self.app.post("/my/upload/path", upload_files = files)
上传文件通常需要经过身份验证的用户,所以你可能还需要通过“extra_environ”参数self.app.post()来规避。
请参阅paste.fixture documentation以了解self.app.post接受的参数的详细信息()