From fd4ccd045cf8edf0bf10ee0c576c7b7c5819170c Mon Sep 17 00:00:00 2001 From: Duncan Parkes Date: Sun, 8 Jun 2014 00:47:43 +0100 Subject: Fixed #22799 -- Made GET and POST on HttpRequest QueryDicts, and FILES a MultiValueDict. Previously, GET, POST, and FILES on an HttpRequest were created in the __init__ method as dictionaries. This was not something you would usually notice causing trouble in production as you'd only see a WSGIRequest, but in testing using the test client, calling .getlist on GET, POST, or FILES for a request with no get/post data resulted in an AttributeError. Changed GET and POST on an HttpRequest object to be mutable QueryDicts (mutable because the Django tests, and probably many third party tests, were expecting it). --- tests/requests/tests.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests') diff --git a/tests/requests/tests.py b/tests/requests/tests.py index 3f30f75eea..b778fe3718 100644 --- a/tests/requests/tests.py +++ b/tests/requests/tests.py @@ -27,6 +27,13 @@ class RequestsTests(SimpleTestCase): self.assertEqual(list(request.COOKIES.keys()), []) self.assertEqual(list(request.META.keys()), []) + # .GET and .POST should be QueryDicts + self.assertEqual(request.GET.urlencode(), '') + self.assertEqual(request.POST.urlencode(), '') + + # and FILES should be MultiValueDict + self.assertEqual(request.FILES.getlist('foo'), []) + def test_httprequest_repr(self): request = HttpRequest() request.path = '/somepath/' -- cgit v1.3