Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.6.x] Fixed an encoding issue in the test client.

Refs #20530.

Backport of 7bb6279 and 476b076 from master.

Conflicts:
	django/test/client.py
  • Loading branch information...
commit 9244447cc4a91c22f8f2668f9667e92a1b2de958 1 parent a357c85
@aaugustin aaugustin authored
Showing with 8 additions and 1 deletion.
  1. +8 −1 django/test/client.py
View
9 django/test/client.py
@@ -335,7 +335,6 @@ def generic(self, method, path,
data = force_bytes(data, settings.DEFAULT_CHARSET)
r = {
'PATH_INFO': self._get_path(parsed),
- 'QUERY_STRING': force_str(parsed[4]),
'REQUEST_METHOD': str(method),
}
if data:
@@ -345,8 +344,16 @@ def generic(self, method, path,
'wsgi.input': FakePayload(data),
})
r.update(extra)
+ # If QUERY_STRING is absent or empty, we want to extract it from the URL.
+ if not r.get('QUERY_STRING'):
+ query_string = force_bytes(parsed[4])
+ # WSGI requires latin-1 encoded strings. See get_path_info().
+ if six.PY3:
+ query_string = query_string.decode('iso-8859-1')
+ r['QUERY_STRING'] = query_string
return self.request(**r)
+
class Client(RequestFactory):
"""
A class that can act as a client for testing purposes.
Please sign in to comment.
Something went wrong with that request. Please try again.