diff options
| author | Michael Howitz <mh@gocept.com> | 2017-02-05 18:37:38 +0100 |
|---|---|---|
| committer | Michael Howitz <mh@gocept.com> | 2017-02-05 18:37:38 +0100 |
| commit | 83d221698cdfb355aae5c12c836001557e4be63f (patch) | |
| tree | 4591303fdb06540521b39e6c343c712d489138dd /tests | |
| parent | 88d1c1b2708f13bfbf31f7041e235bd43d75c57d (diff) | |
| download | webtest-83d221698cdfb355aae5c12c836001557e4be63f.tar.gz | |
Fix #173: Do not omit file uploads without a file from post.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_forms.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/tests/test_forms.py b/tests/test_forms.py index 474e766..62f30e6 100644 --- a/tests/test_forms.py +++ b/tests/test_forms.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals +import cgi import os.path import struct import sys @@ -776,9 +777,12 @@ class SingleUploadFileApp(object): uploaded_files = [(k, v) for k, v in req.POST.items() if 'file' in k] uploaded_files = sorted(uploaded_files) for name, uploaded_file in uploaded_files: - filename = to_bytes(uploaded_file.filename) - value = to_bytes(uploaded_file.value, 'ascii') - content_type = to_bytes(uploaded_file.type, 'ascii') + if isinstance(uploaded_file, cgi.FieldStorage): + filename = to_bytes(uploaded_file.filename) + value = to_bytes(uploaded_file.value, 'ascii') + content_type = to_bytes(uploaded_file.type, 'ascii') + else: + filename = value = content_type = b'' file_parts.append(b""" <p>You selected '""" + filename + b"""'</p> <p>with contents: '""" + value + b"""'</p> |
