[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.
This commit is contained in:
Aymeric Augustin 2013-09-07 13:13:21 -05:00
parent 7b8037f3aa
commit 63b95ca452
1 changed files with 15 additions and 3 deletions

View File

@ -271,9 +271,13 @@ class RequestFactory(object):
"Construct a GET request." "Construct a GET request."
parsed = urlparse(path) 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 = { r = {
'PATH_INFO': self._get_path(parsed), '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'), 'REQUEST_METHOD': str('GET'),
} }
r.update(extra) r.update(extra)
@ -286,11 +290,15 @@ class RequestFactory(object):
post_data = self._encode_data(data, content_type) post_data = self._encode_data(data, content_type)
parsed = urlparse(path) parsed = urlparse(path)
query_string = force_str(parsed[4])
if six.PY3:
query_string = query_string.encode('utf-8').decode('iso-8859-1')
r = { r = {
'CONTENT_LENGTH': len(post_data), 'CONTENT_LENGTH': len(post_data),
'CONTENT_TYPE': content_type, 'CONTENT_TYPE': content_type,
'PATH_INFO': self._get_path(parsed), 'PATH_INFO': self._get_path(parsed),
'QUERY_STRING': force_str(parsed[4]), 'QUERY_STRING': query_string,
'REQUEST_METHOD': str('POST'), 'REQUEST_METHOD': str('POST'),
'wsgi.input': FakePayload(post_data), 'wsgi.input': FakePayload(post_data),
} }
@ -301,9 +309,13 @@ class RequestFactory(object):
"Construct a HEAD request." "Construct a HEAD request."
parsed = urlparse(path) 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 = { r = {
'PATH_INFO': self._get_path(parsed), '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'), 'REQUEST_METHOD': str('HEAD'),
} }
r.update(extra) r.update(extra)