Ticket #18481: t18481_test.patch

File t18481_test.patch, 1.1 KB (added by Hiroki Kiyohara, 12 years ago)

Patch for testing

  • tests/regressiontests/requests/tests.py

    diff --git a/tests/regressiontests/requests/tests.py b/tests/regressiontests/requests/tests.py
    index 799cd9b..43e0475 100644
    a b class RequestsTests(unittest.TestCase):  
    524524
    525525        with self.assertRaises(UnreadablePostError):
    526526            request.body
     527
     528    def test_FILES_connection_error(self):
     529        """
     530        If wsgi.input.read() raises an exception while trying to read() the
     531        POST, the exception should be identifiable (not a generic IOError).
     532        """
     533        class ExplodingBytesIO(BytesIO):
     534            def read(self, len=0):
     535                raise IOError("kaboom!")
     536
     537        payload = b'x'
     538        request = WSGIRequest({'REQUEST_METHOD': 'POST',
     539                               'CONTENT_TYPE': 'multipart/form-data; boundary=foo_',
     540                               'CONTENT_LENGTH': len(payload),
     541                               'wsgi.input': ExplodingBytesIO(payload)})
     542
     543        with self.assertRaises(UnreadablePostError):
     544            request.FILES
Back to Top