Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.6.x] Fixed 9244447 -- incomplete backport.

The test client had been refactored in the mean time. This commit
de-factors the fix. Refs #20530.
  • Loading branch information...
commit 63b95ca452ea7ef1103e599f8dd733b67278c8dc 1 parent 7b8037f
@aaugustin aaugustin authored
Showing with 15 additions and 3 deletions.
  1. +15 −3 django/test/client.py
View
18 django/test/client.py
@@ -271,9 +271,13 @@ def get(self, path, data={}, **extra):
"Construct a GET request."
parsed = urlparse(path)
+ query_string = urlencode(data, doseq=True) or force_str(parsed[4])
+ if six.PY3:
+ query_string = query_string.encode('utf-8').decode('iso-8859-1')
+
r = {
'PATH_INFO': self._get_path(parsed),
- 'QUERY_STRING': urlencode(data, doseq=True) or force_str(parsed[4]),
+ 'QUERY_STRING': query_string,
'REQUEST_METHOD': str('GET'),
}
r.update(extra)
@@ -286,11 +290,15 @@ def post(self, path, data={}, content_type=MULTIPART_CONTENT,
post_data = self._encode_data(data, content_type)
parsed = urlparse(path)
+ query_string = force_str(parsed[4])
+ if six.PY3:
+ query_string = query_string.encode('utf-8').decode('iso-8859-1')
+
r = {
'CONTENT_LENGTH': len(post_data),
'CONTENT_TYPE': content_type,
'PATH_INFO': self._get_path(parsed),
- 'QUERY_STRING': force_str(parsed[4]),
+ 'QUERY_STRING': query_string,
'REQUEST_METHOD': str('POST'),
'wsgi.input': FakePayload(post_data),
}
@@ -301,9 +309,13 @@ def head(self, path, data={}, **extra):
"Construct a HEAD request."
parsed = urlparse(path)
+ query_string = urlencode(data, doseq=True) or force_str(parsed[4])
+ if six.PY3:
+ query_string = query_string.encode('utf-8').decode('iso-8859-1')
+
r = {
'PATH_INFO': self._get_path(parsed),
- 'QUERY_STRING': urlencode(data, doseq=True) or force_str(parsed[4]),
+ 'QUERY_STRING': query_string,
'REQUEST_METHOD': str('HEAD'),
}
r.update(extra)
Please sign in to comment.
Something went wrong with that request. Please try again.