diff options
| author | Gael Pasgrimaud <gael@gawel.org> | 2018-05-18 12:31:48 +0200 |
|---|---|---|
| committer | Gael Pasgrimaud <gael@gawel.org> | 2018-05-18 12:31:48 +0200 |
| commit | 25bfadac1d3288fb5f52b36081c636e836694372 (patch) | |
| tree | f0c41c5f5d385022e399a9f7c32cd49a921df1db | |
| parent | 4e29ce304e2295e6c68b2974945b1dc5aa0bc6d3 (diff) | |
| download | webtest-25bfadac1d3288fb5f52b36081c636e836694372.tar.gz | |
fixed #193
| -rw-r--r-- | tests/test_forms.py | 15 | ||||
| -rw-r--r-- | webtest/forms.py | 2 |
2 files changed, 16 insertions, 1 deletions
diff --git a/tests/test_forms.py b/tests/test_forms.py index f97071f..af78ce5 100644 --- a/tests/test_forms.py +++ b/tests/test_forms.py @@ -1043,3 +1043,18 @@ class TestFileUpload(unittest.TestCase): ) resp.mustcontain("<p>You selected 'filename'</p>", "<p>with contents: 'content'</p>") + + def test_post_upload_empty_files(self): + app = webtest.TestApp(SingleUploadFileApp()) + resp = app.post( + '/', + upload_files=[('file', 'filename', b'')] + ) + resp.mustcontain("<p>You selected 'filename'</p>", + "<p>with contents: ''</p>") + resp = app.get('/') + form = resp.form + form['file-field'] = Upload('filename', b'', 'text/plain') + resp = form.submit() + resp.mustcontain("<p>You selected 'filename'</p>", + "<p>with contents: ''</p>") diff --git a/webtest/forms.py b/webtest/forms.py index 2a5ff8d..0fb9789 100644 --- a/webtest/forms.py +++ b/webtest/forms.py @@ -38,7 +38,7 @@ class Upload(object): def __iter__(self): yield self.filename - if self.content: + if self.content is not None: yield self.content yield self.content_type # TODO: do we handle the case when we need to get |
