Loading django/test/client.py +13 −6 Original line number Diff line number Diff line Loading @@ -203,13 +203,20 @@ class RequestFactory(object): "Construct a generic request object." return WSGIRequest(self._base_environ(**request)) def _get_path(self, parsed): # If there are parameters, add them if parsed[3]: return urllib.unquote(parsed[2] + ";" + parsed[3]) else: return urllib.unquote(parsed[2]) def get(self, path, data={}, **extra): "Construct a GET request" parsed = urlparse(path) r = { 'CONTENT_TYPE': 'text/html; charset=utf-8', 'PATH_INFO': urllib.unquote(parsed[2]), 'PATH_INFO': self._get_path(parsed), 'QUERY_STRING': urlencode(data, doseq=True) or parsed[4], 'REQUEST_METHOD': 'GET', 'wsgi.input': FakePayload('') Loading @@ -236,7 +243,7 @@ class RequestFactory(object): r = { 'CONTENT_LENGTH': len(post_data), 'CONTENT_TYPE': content_type, 'PATH_INFO': urllib.unquote(parsed[2]), 'PATH_INFO': self._get_path(parsed), 'QUERY_STRING': parsed[4], 'REQUEST_METHOD': 'POST', 'wsgi.input': FakePayload(post_data), Loading @@ -250,7 +257,7 @@ class RequestFactory(object): parsed = urlparse(path) r = { 'CONTENT_TYPE': 'text/html; charset=utf-8', 'PATH_INFO': urllib.unquote(parsed[2]), 'PATH_INFO': self._get_path(parsed), 'QUERY_STRING': urlencode(data, doseq=True) or parsed[4], 'REQUEST_METHOD': 'HEAD', 'wsgi.input': FakePayload('') Loading @@ -263,7 +270,7 @@ class RequestFactory(object): parsed = urlparse(path) r = { 'PATH_INFO': urllib.unquote(parsed[2]), 'PATH_INFO': self._get_path(parsed), 'QUERY_STRING': urlencode(data, doseq=True) or parsed[4], 'REQUEST_METHOD': 'OPTIONS', 'wsgi.input': FakePayload('') Loading @@ -290,7 +297,7 @@ class RequestFactory(object): r = { 'CONTENT_LENGTH': len(post_data), 'CONTENT_TYPE': content_type, 'PATH_INFO': urllib.unquote(parsed[2]), 'PATH_INFO': self._get_path(parsed), 'QUERY_STRING': query_string or parsed[4], 'REQUEST_METHOD': 'PUT', 'wsgi.input': FakePayload(post_data), Loading @@ -303,7 +310,7 @@ class RequestFactory(object): parsed = urlparse(path) r = { 'PATH_INFO': urllib.unquote(parsed[2]), 'PATH_INFO': self._get_path(parsed), 'QUERY_STRING': urlencode(data, doseq=True) or parsed[4], 'REQUEST_METHOD': 'DELETE', 'wsgi.input': FakePayload('') Loading tests/modeltests/test_client/models.py +7 −0 Original line number Diff line number Diff line Loading @@ -269,6 +269,13 @@ class ClientTest(TestCase): # Check that the response was a 404 self.assertEqual(response.status_code, 404) def test_url_parameters(self): "Make sure that URL ;-parameters are not stripped." response = self.client.get('/test_client/unknown_view/;some-parameter') # Check that the path in the response includes it (ignore that it's a 404) self.assertEqual(response.request['PATH_INFO'], '/test_client/unknown_view/;some-parameter') def test_view_with_login(self): "Request a page that is protected with @login_required" Loading Loading
django/test/client.py +13 −6 Original line number Diff line number Diff line Loading @@ -203,13 +203,20 @@ class RequestFactory(object): "Construct a generic request object." return WSGIRequest(self._base_environ(**request)) def _get_path(self, parsed): # If there are parameters, add them if parsed[3]: return urllib.unquote(parsed[2] + ";" + parsed[3]) else: return urllib.unquote(parsed[2]) def get(self, path, data={}, **extra): "Construct a GET request" parsed = urlparse(path) r = { 'CONTENT_TYPE': 'text/html; charset=utf-8', 'PATH_INFO': urllib.unquote(parsed[2]), 'PATH_INFO': self._get_path(parsed), 'QUERY_STRING': urlencode(data, doseq=True) or parsed[4], 'REQUEST_METHOD': 'GET', 'wsgi.input': FakePayload('') Loading @@ -236,7 +243,7 @@ class RequestFactory(object): r = { 'CONTENT_LENGTH': len(post_data), 'CONTENT_TYPE': content_type, 'PATH_INFO': urllib.unquote(parsed[2]), 'PATH_INFO': self._get_path(parsed), 'QUERY_STRING': parsed[4], 'REQUEST_METHOD': 'POST', 'wsgi.input': FakePayload(post_data), Loading @@ -250,7 +257,7 @@ class RequestFactory(object): parsed = urlparse(path) r = { 'CONTENT_TYPE': 'text/html; charset=utf-8', 'PATH_INFO': urllib.unquote(parsed[2]), 'PATH_INFO': self._get_path(parsed), 'QUERY_STRING': urlencode(data, doseq=True) or parsed[4], 'REQUEST_METHOD': 'HEAD', 'wsgi.input': FakePayload('') Loading @@ -263,7 +270,7 @@ class RequestFactory(object): parsed = urlparse(path) r = { 'PATH_INFO': urllib.unquote(parsed[2]), 'PATH_INFO': self._get_path(parsed), 'QUERY_STRING': urlencode(data, doseq=True) or parsed[4], 'REQUEST_METHOD': 'OPTIONS', 'wsgi.input': FakePayload('') Loading @@ -290,7 +297,7 @@ class RequestFactory(object): r = { 'CONTENT_LENGTH': len(post_data), 'CONTENT_TYPE': content_type, 'PATH_INFO': urllib.unquote(parsed[2]), 'PATH_INFO': self._get_path(parsed), 'QUERY_STRING': query_string or parsed[4], 'REQUEST_METHOD': 'PUT', 'wsgi.input': FakePayload(post_data), Loading @@ -303,7 +310,7 @@ class RequestFactory(object): parsed = urlparse(path) r = { 'PATH_INFO': urllib.unquote(parsed[2]), 'PATH_INFO': self._get_path(parsed), 'QUERY_STRING': urlencode(data, doseq=True) or parsed[4], 'REQUEST_METHOD': 'DELETE', 'wsgi.input': FakePayload('') Loading
tests/modeltests/test_client/models.py +7 −0 Original line number Diff line number Diff line Loading @@ -269,6 +269,13 @@ class ClientTest(TestCase): # Check that the response was a 404 self.assertEqual(response.status_code, 404) def test_url_parameters(self): "Make sure that URL ;-parameters are not stripped." response = self.client.get('/test_client/unknown_view/;some-parameter') # Check that the path in the response includes it (ignore that it's a 404) self.assertEqual(response.request['PATH_INFO'], '/test_client/unknown_view/;some-parameter') def test_view_with_login(self): "Request a page that is protected with @login_required" Loading