diff options
| author | Claude Paroz <claude@2xlibre.net> | 2013-06-01 10:26:46 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2013-06-01 10:26:46 +0200 |
| commit | de66b56790598f2ff97b8df859356d755ce64e20 (patch) | |
| tree | 5a91cdf2e4c8f6543f23bf1d2ec8ca20543a5ffd /tests | |
| parent | 369b6fab25b55ceb363ba2a8cb7e0f1a88ef8f8d (diff) | |
Fixed #18481 -- Wrapped request.FILES read error in UnreadablePostError
Thanks KyleMac for the report, André Cruz for the initial patch and
Hiroki Kiyohara for the tests.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/requests/tests.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/requests/tests.py b/tests/requests/tests.py index 676cd05679..4d730bb561 100644 --- a/tests/requests/tests.py +++ b/tests/requests/tests.py @@ -659,6 +659,24 @@ class RequestsTests(SimpleTestCase): with self.assertRaises(UnreadablePostError): request.body + def test_FILES_connection_error(self): + """ + If wsgi.input.read() raises an exception while trying to read() the + FILES, the exception should be identifiable (not a generic IOError). + """ + class ExplodingBytesIO(BytesIO): + def read(self, len=0): + raise IOError("kaboom!") + + payload = b'x' + request = WSGIRequest({'REQUEST_METHOD': 'POST', + 'CONTENT_TYPE': 'multipart/form-data; boundary=foo_', + 'CONTENT_LENGTH': len(payload), + 'wsgi.input': ExplodingBytesIO(payload)}) + + with self.assertRaises(UnreadablePostError): + request.FILES + @skipIf(connection.vendor == 'sqlite' and connection.settings_dict['NAME'] in ('', ':memory:'), |
