diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-12-17 10:49:26 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-12-22 13:32:39 +0100 |
| commit | 1e4a27d08790c96f657d2e960c8142d1ca69aede (patch) | |
| tree | 0f628babc0ea651867a223fbf7d9281bb2ce218b /tests/regressiontests/requests/tests.py | |
| parent | d9a0b6ab36b6beb4251acf1de1fdf255e1223e02 (diff) | |
Fixed #19468 -- Decoded request.path correctly on Python 3.
Thanks aliva for the report and claudep for the feedback.
Diffstat (limited to 'tests/regressiontests/requests/tests.py')
| -rw-r--r-- | tests/regressiontests/requests/tests.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/regressiontests/requests/tests.py b/tests/regressiontests/requests/tests.py index adf824dff7..bb7f925e87 100644 --- a/tests/regressiontests/requests/tests.py +++ b/tests/regressiontests/requests/tests.py @@ -11,6 +11,7 @@ from django.core.handlers.wsgi import WSGIRequest, LimitedStream from django.http import HttpRequest, HttpResponse, parse_cookie, build_request_repr, UnreadablePostError from django.test.client import FakePayload from django.test.utils import override_settings, str_prefix +from django.utils import six from django.utils import unittest from django.utils.http import cookie_date, urlencode from django.utils.timezone import utc @@ -57,6 +58,16 @@ class RequestsTests(unittest.TestCase): self.assertEqual(build_request_repr(request, path_override='/otherpath/', GET_override={'a': 'b'}, POST_override={'c': 'd'}, COOKIES_override={'e': 'f'}, META_override={'g': 'h'}), str_prefix("<WSGIRequest\npath:/otherpath/,\nGET:{%(_)s'a': %(_)s'b'},\nPOST:{%(_)s'c': %(_)s'd'},\nCOOKIES:{%(_)s'e': %(_)s'f'},\nMETA:{%(_)s'g': %(_)s'h'}>")) + def test_wsgirequest_path_info(self): + def wsgi_str(path_info): + path_info = path_info.encode('utf-8') # Actual URL sent by the browser (bytestring) + if six.PY3: + path_info = path_info.decode('iso-8859-1') # Value in the WSGI environ dict (native string) + return path_info + # Regression for #19468 + request = WSGIRequest({'PATH_INFO': wsgi_str("/سلام/"), 'REQUEST_METHOD': 'get', 'wsgi.input': BytesIO(b'')}) + self.assertEqual(request.path, "/سلام/") + def test_parse_cookie(self): self.assertEqual(parse_cookie('invalid@key=true'), {}) |
