mirror of https://github.com/django/django.git
[1.6.x] Fixed an encoding issue in the test client.
Refs #20530. Backport of7bb62793
and476b0764
from master. Conflicts: django/test/client.py
This commit is contained in:
parent
a357c854c9
commit
9244447cc4
|
@ -335,7 +335,6 @@ class RequestFactory(object):
|
||||||
data = force_bytes(data, settings.DEFAULT_CHARSET)
|
data = force_bytes(data, settings.DEFAULT_CHARSET)
|
||||||
r = {
|
r = {
|
||||||
'PATH_INFO': self._get_path(parsed),
|
'PATH_INFO': self._get_path(parsed),
|
||||||
'QUERY_STRING': force_str(parsed[4]),
|
|
||||||
'REQUEST_METHOD': str(method),
|
'REQUEST_METHOD': str(method),
|
||||||
}
|
}
|
||||||
if data:
|
if data:
|
||||||
|
@ -345,8 +344,16 @@ class RequestFactory(object):
|
||||||
'wsgi.input': FakePayload(data),
|
'wsgi.input': FakePayload(data),
|
||||||
})
|
})
|
||||||
r.update(extra)
|
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)
|
return self.request(**r)
|
||||||
|
|
||||||
|
|
||||||
class Client(RequestFactory):
|
class Client(RequestFactory):
|
||||||
"""
|
"""
|
||||||
A class that can act as a client for testing purposes.
|
A class that can act as a client for testing purposes.
|
||||||
|
|
Loading…
Reference in New Issue