summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-09-07 13:13:21 -0500
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-09-07 13:15:13 -0500
commit63b95ca452ea7ef1103e599f8dd733b67278c8dc (patch)
tree64526bc1c58340abe5ea8f37bd6e7df645f7ffcb
parent7b8037f3aa880397d16c7a11647d53f92b7cec67 (diff)
[1.6.x] Fixed 9244447c -- incomplete backport.
The test client had been refactored in the mean time. This commit de-factors the fix. Refs #20530.
-rw-r--r--django/test/client.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/django/test/client.py b/django/test/client.py
index 2196805c4c..fb9a9e7a02 100644
--- a/django/test/client.py
+++ b/django/test/client.py
@@ -271,9 +271,13 @@ class RequestFactory(object):
"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 @@ class RequestFactory(object):
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 @@ class RequestFactory(object):
"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)