Code

Ticket #19101: 19101-test.diff

File 19101-test.diff, 1.4 KB (added by claudep, 21 months ago)

Test failing on Python 3

Line 
1diff --git a/tests/regressiontests/requests/tests.py b/tests/regressiontests/requests/tests.py
2index f9e1112..cb4ec53 100644
3--- a/tests/regressiontests/requests/tests.py
4+++ b/tests/regressiontests/requests/tests.py
5@@ -1,3 +1,4 @@
6+# -*- encoding: utf-8 -*-
7 from __future__ import unicode_literals
8 
9 import time
10@@ -10,7 +11,7 @@ from django.core.handlers.wsgi import WSGIRequest, LimitedStream
11 from django.http import HttpRequest, HttpResponse, parse_cookie, build_request_repr, UnreadablePostError
12 from django.test.utils import str_prefix
13 from django.utils import unittest
14-from django.utils.http import cookie_date
15+from django.utils.http import cookie_date, urlencode
16 from django.utils.timezone import utc
17 
18 
19@@ -295,6 +296,16 @@ class RequestsTests(unittest.TestCase):
20         self.assertRaises(Exception, lambda: request.body)
21         self.assertEqual(request.POST, {})
22 
23+    def test_non_ascii_POST(self):
24+        payload = urlencode({'key': 'España'}).encode('utf-8')
25+        request = WSGIRequest({
26+            'REQUEST_METHOD': 'POST',
27+            'CONTENT_LENGTH': len(payload),
28+            'CONTENT_TYPE': 'application/x-www-form-urlencoded',
29+            'wsgi.input': BytesIO(payload)
30+        })
31+        self.assertEqual(request.POST, {'key': ['España']})
32+
33     def test_body_after_POST_multipart(self):
34         """
35         Reading body after parsing multipart is not allowed