[Django] #22079: TestClient serialization of POST params with empty list as value

13 views
Skip to first unread message

Django

unread,
Feb 17, 2014, 12:23:59 PM2/17/14
to django-...@googlegroups.com
#22079: TestClient serialization of POST params with empty list as value
------------------------------------------+--------------------
Reporter: code.djangoproject.com@… | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Easy pickings: 0 | UI/UX: 0
------------------------------------------+--------------------
Problem:
When POST-ing a parameter whose value is the empty list, TestClient will
strip that param-value pair out of the request entirely. In contrast to
GET, which passes these along.

Expected behaviour:
They should work the same in the face of an empty list value.

See: https://github.com/django/django/pull/2268 for a patch making POST
behave as GET.

--
Ticket URL: <https://code.djangoproject.com/ticket/22079>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 20, 2014, 2:36:30 PM3/20/14
to django-...@googlegroups.com
#22079: TestClient serialization of POST params with empty list as value
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
code.djangoproject.com@… | Status: new
Type: Bug | Version: master
Component: Testing framework | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by aaugustin):

* needs_docs: => 0
* needs_better_patch: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted


Comment:

As noted on the pull request, we may want to fix GET rather than POST.

In any case, they should behave similarly.

--
Ticket URL: <https://code.djangoproject.com/ticket/22079#comment:1>

Django

unread,
Jun 5, 2014, 8:22:47 PM6/5/14
to django-...@googlegroups.com
#22079: TestClient serialization of POST params with empty list as value
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
code.djangoproject.com@… | Status: new
Type: Bug | Version: master
Component: Testing framework | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1

Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/22079#comment:2>

Django

unread,
Jun 9, 2014, 9:50:43 AM6/9/14
to django-...@googlegroups.com
#22079: TestClient serialization of POST params with empty list as value
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
code.djangoproject.com@… | Status: new
Type: Bug | Version: master
Component: Testing framework | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by gchp):

* cc: gregchapple1@… (added)


Comment:

What is the desired behaviour here?

From what I can see, the difference lies with using
`django.utils.http.urlencode` to process the get params.

{{{
>>> from django.utils.http import urlencode

>>> data = {'test': ['value1', 'value2']
>>> urlencode(data, doseq=True)
'test=value1&test=value2'

>>> data = {'test': []}
>>> urlencode(data, doseq=True)
''
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22079#comment:3>

Django

unread,
Oct 13, 2014, 1:20:30 PM10/13/14
to django-...@googlegroups.com
#22079: TestClient serialization of POST params with empty list as value
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
code.djangoproject.com@… | Status: new
Type: Bug | Version: master
Component: Testing framework | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by apollo13):

* cc: apollo13 (added)


Comment:

From my gut I'd say that empty lists should get stripped out entirely,
cause there is no way to represent an empty list, "?test=" would be
interpreted as a list with one empty item in .getlist which makes no
sense.

--
Ticket URL: <https://code.djangoproject.com/ticket/22079#comment:4>

Django

unread,
Dec 28, 2014, 12:46:00 AM12/28/14
to django-...@googlegroups.com
#22079: TestClient serialization of GET params with empty list as value

-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
code.djangoproject.com@… |
Type: Bug | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/22079#comment:5>

Django

unread,
May 13, 2020, 7:21:35 AM5/13/20
to django-...@googlegroups.com
#22079: TestClient serialization of GET params with empty list as value
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
code.djangoproject.com@… |
Type: Bug | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ahmad Abdallah):

* needs_better_patch: 1 => 0
* has_patch: 1 => 0


Comment:

What's the desired behavior here? If it's correcting getlist's handling of
empty lists, isn't that more in line with altering QueryDict than changing
serialization of GET params?

If we're still changing serialization, we might have to rewrite it
ourselves since our current serialization is derived from urllib which is
what causes the current bug mentioned by the ticket.

--
Ticket URL: <https://code.djangoproject.com/ticket/22079#comment:6>

Django

unread,
May 13, 2020, 7:21:56 AM5/13/20
to django-...@googlegroups.com
#22079: TestClient serialization of GET params with empty list as value
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
code.djangoproject.com@… |
Type: Bug | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ahmad Abdallah):

* cc: Ahmad Abdallah (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/22079#comment:7>

Django

unread,
May 20, 2020, 4:07:35 PM5/20/20
to django-...@googlegroups.com
#22079: TestClient serialization of GET params with empty list as value
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
code.djangoproject.com@… |
Type: Bug | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tom Forbes):

* cc: Tom Forbes (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/22079#comment:8>

Reply all
Reply to author
Forward
0 new messages