diff -r e695e5b1ed4d tests/test_file_upload.py
|
a
|
b
|
|
| 136 | 136 | |
| 137 | 137 | def test_no_uploads_error(): |
| 138 | 138 | app = webtest.TestApp(single_upload_file_app) |
| 139 | | uploads = app.get('/').forms["file_upload_form"].upload_fields() |
| | 139 | single_form = app.get('/').forms["file_upload_form"] |
| | 140 | single_form.submit("button") |
| 140 | 141 | |
| 141 | 142 | |
| 142 | 143 | def test_file_upload_with_filename_only(): |
diff -r e695e5b1ed4d webtest/__init__.py
|
a
|
b
|
|
| 252 | 252 | lines.append('') |
| 253 | 253 | lines.append(value) |
| 254 | 254 | for file_info in files: |
| 255 | | key, filename, value = self._get_file_info(file_info) |
| 256 | | lines.append('--'+boundary) |
| 257 | | lines.append('Content-Disposition: form-data; name="%s"; filename="%s"' |
| 258 | | % (key, filename)) |
| 259 | | fcontent = mimetypes.guess_type(filename)[0] |
| 260 | | lines.append('Content-Type: %s' % |
| 261 | | fcontent or 'application/octet-stream') |
| 262 | | lines.append('') |
| 263 | | lines.append(value) |
| | 255 | if len(file_info) > 1: |
| | 256 | key, filename, value = self._get_file_info(file_info) |
| | 257 | lines.append('--'+boundary) |
| | 258 | lines.append('Content-Disposition: form-data; name="%s"; filename="%s"' |
| | 259 | % (key, filename)) |
| | 260 | fcontent = mimetypes.guess_type(filename)[0] |
| | 261 | lines.append('Content-Type: %s' % |
| | 262 | fcontent or 'application/octet-stream') |
| | 263 | lines.append('') |
| | 264 | lines.append(value) |
| 264 | 265 | lines.append('--' + boundary + '--') |
| 265 | 266 | lines.append('') |
| 266 | 267 | body = '\r\n'.join(lines) |