It seems that webtest cannot handle multiple file fields:
Here files is a <input type="file" name="files" multiple /> input.
from webtest import Upload
def test_foobar(app):
res = app.get("/my-form")
res.form["files"] = [Upload("foo.txt", b"foo"), Upload("bar.txt", b"bar")]
res = res.form.submit()
Here is the last frame of the generated stack trace:
self = <webtest.app.TestApp object at 0x7f7b3eceb3a0>, file_info = [b'files', <Upload "foo.png">, <Upload "bar.png">]
def _get_file_info(self, file_info):
if len(file_info) == 2:
# It only has a filename
filename = file_info[1]
if self.relative_to:
filename = os.path.join(self.relative_to, filename)
f = open(filename, 'rb')
content = f.read()
f.close()
return (file_info[0], filename, content, None)
elif 3 <= len(file_info) <= 4:
content = file_info[2]
if not isinstance(content, bytes):
> raise ValueError('File content must be %s not %s'
% (bytes, type(content)))
E ValueError: File content must be <class 'bytes'> not <class 'webtest.forms.Upload'>
I suggest making webtest handle multiple file fields.
It seems that webtest cannot handle multiple file fields:
Here
files
is a<input type="file" name="files" multiple />
input.Here is the last frame of the generated stack trace:
I suggest making webtest handle multiple file fields.