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 14:45:06 +0100 |
| commit | 99196381374c5f88b7138236aa5d6a969e281590 (patch) | |
| tree | 42190df36e0af70848385190496ea80472c66a7d /tests/regressiontests | |
| parent | db22145afb9623fdcaa4269b5eefa045320e028e (diff) | |
[1.5.x] Fixed #19468 -- Decoded request.path correctly on Python 3.
Thanks aliva for the report and claudep for the feedback.
Backport of 1e4a27d from master.
Diffstat (limited to 'tests/regressiontests')
| -rw-r--r-- | tests/regressiontests/handlers/tests.py | 3 | ||||
| -rw-r--r-- | tests/regressiontests/requests/tests.py | 11 |
2 files changed, 13 insertions, 1 deletions
diff --git a/tests/regressiontests/handlers/tests.py b/tests/regressiontests/handlers/tests.py index 8676a448d9..9cd5816219 100644 --- a/tests/regressiontests/handlers/tests.py +++ b/tests/regressiontests/handlers/tests.py @@ -1,6 +1,7 @@ from django.core.handlers.wsgi import WSGIHandler from django.test import RequestFactory from django.test.utils import override_settings +from django.utils import six from django.utils import unittest class HandlerTests(unittest.TestCase): @@ -22,7 +23,7 @@ class HandlerTests(unittest.TestCase): def test_bad_path_info(self): """Tests for bug #15672 ('request' referenced before assignment)""" environ = RequestFactory().get('/').environ - environ['PATH_INFO'] = b'\xed' + environ['PATH_INFO'] = '\xed' handler = WSGIHandler() response = handler(environ, lambda *a, **k: None) self.assertEqual(response.status_code, 400) 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'), {}) |
