mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-10 19:56:59 +03:00
Reintroduced url arguments in the urls for the tests.
This commit is contained in:
parent
6cf19fa4ef
commit
0e677e9dd1
|
@ -76,6 +76,10 @@ 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]
|
||||
r.update(extra)
|
||||
return self.generic('GET', path, **r)
|
||||
|
||||
|
|
|
@ -152,3 +152,13 @@ class TestAPIRequestFactory(TestCase):
|
|||
simple_png.name = 'test.png'
|
||||
factory = APIRequestFactory()
|
||||
factory.post('/', data={'image': simple_png})
|
||||
|
||||
def test_request_factory_url_arguments(self):
|
||||
"""
|
||||
This is a non regression test against #1461
|
||||
"""
|
||||
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