mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-10 19:56:59 +03:00
Fix APIClient.get() when path contains unicode arguments (#4458)
This commit is contained in:
parent
80bd3b9722
commit
07efbdb45e
|
@ -79,10 +79,13 @@ class APIRequestFactory(DjangoRequestFactory):
|
|||
r = {
|
||||
'QUERY_STRING': urlencode(data or {}, doseq=True),
|
||||
}
|
||||
# Fix to support old behavior where you have the arguments in the url
|
||||
# See #1461
|
||||
if not data and '?' in path:
|
||||
r['QUERY_STRING'] = path.split('?')[1]
|
||||
# Fix to support old behavior where you have the arguments in the
|
||||
# url. See #1461.
|
||||
query_string = force_bytes(path.split('?')[1])
|
||||
if six.PY3:
|
||||
query_string = query_string.decode('iso-8859-1')
|
||||
r['QUERY_STRING'] = query_string
|
||||
r.update(extra)
|
||||
return self.generic('GET', path, **r)
|
||||
|
||||
|
|
|
@ -245,3 +245,10 @@ class TestAPIRequestFactory(TestCase):
|
|||
self.assertEqual(dict(request.GET), {'demo': ['test']})
|
||||
request = factory.get('/view/', {'demo': 'test'})
|
||||
self.assertEqual(dict(request.GET), {'demo': ['test']})
|
||||
|
||||
def test_request_factory_url_arguments_with_unicode(self):
|
||||
factory = APIRequestFactory()
|
||||
request = factory.get('/view/?demo=testé')
|
||||
self.assertEqual(dict(request.GET), {'demo': ['testé']})
|
||||
request = factory.get('/view/', {'demo': 'testé'})
|
||||
self.assertEqual(dict(request.GET), {'demo': ['testé']})
|
||||
|
|
Loading…
Reference in New Issue
Block a user