Ticket #19101: 19101-test.diff

File 19101-test.diff, 1.4 KB (added by claudep, 3 years ago)

Test failing on Python 3

  • tests/regressiontests/requests/tests.py

    diff --git a/tests/regressiontests/requests/tests.py b/tests/regressiontests/requests/tests.py
    index f9e1112..cb4ec53 100644
    a b  
     1# -*- encoding: utf-8 -*-
    12from __future__ import unicode_literals
    23
    34import time
    from django.core.handlers.wsgi import WSGIRequest, LimitedStream 
    1011from django.http import HttpRequest, HttpResponse, parse_cookie, build_request_repr, UnreadablePostError
    1112from django.test.utils import str_prefix
    1213from django.utils import unittest
    13 from django.utils.http import cookie_date
     14from django.utils.http import cookie_date, urlencode
    1415from django.utils.timezone import utc
    1516
    1617
    class RequestsTests(unittest.TestCase): 
    295296        self.assertRaises(Exception, lambda: request.body)
    296297        self.assertEqual(request.POST, {})
    297298
     299    def test_non_ascii_POST(self):
     300        payload = urlencode({'key': 'España'}).encode('utf-8')
     301        request = WSGIRequest({
     302            'REQUEST_METHOD': 'POST',
     303            'CONTENT_LENGTH': len(payload),
     304            'CONTENT_TYPE': 'application/x-www-form-urlencoded',
     305            'wsgi.input': BytesIO(payload)
     306        })
     307        self.assertEqual(request.POST, {'key': ['España']})
     308
    298309    def test_body_after_POST_multipart(self):
    299310        """
    300311        Reading body after parsing multipart is not allowed
Back to Top