[Django] #17631: edge case: django.test.client should handle fields and files with the same name

17 views
Skip to first unread message

Django

unread,
Feb 2, 2012, 6:35:13 PM2/2/12
to django-...@googlegroups.com
#17631: edge case: django.test.client should handle fields and files with the same
name
-------------------------------+--------------------
Reporter: dnozay | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.3
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
problem:
- want to upload file with very common name, e.g. 'somefield'
- want to post data with very common name for field, e.g. 'somefield'

http://www.scotthawker.com/scott/?p=1892

http://code.activestate.com/recipes/146306/

{{{
>>> fields = { 'somefield': 1 }
>>> files = { 'somefield': open('/dev/null', 'r') }
>>> data = QueryDict('', mutable=True)
>>> data.update(fields)
>>> data.update(files)
>>> data
<QueryDict: {u'somefield': [1, <open file '/dev/null', mode 'r' at
0x8a0c610>]}>
>>> data.items()
[(u'somefield', <open file '/dev/null', mode 'r' at 0x8a0c610>)]
>>> data
<QueryDict: {u'somefield': [1, <open file '/dev/null', mode 'r' at
0x8a0c610>]}>
>>>
>>> from django.utils.datastructures import MultiValueDict
>>> data = MultiValueDict()
>>> data.update(fields)
>>> data.update(files)
>>> data
<MultiValueDict: {'somefield': [1, <open file '/dev/null', mode 'r' at
0x8a0c610>]}>
>>> data.items()
[('somefield', <open file '/dev/null', mode 'r' at 0x8a0c610>)]
>>> data['somefield']
<open file '/dev/null', mode 'r' at 0x8a0c610>
>>> data.getlist('somefield')
[1, <open file '/dev/null', mode 'r' at 0x8a0c610>]
>>>
}}}


https://code.djangoproject.com/browser/django/trunk/django/test/client.py

{{{
116 # Each bit of the multipart form data could be either a form
value or a
117 # file, or a *list* of form values and/or files. Remember that
HTTP field
118 # names can be duplicated!
119 for (key, value) in data.items():
}}}

IMHO, the test client should use data.lists() instead when providing
MultiValueDict or subclass.

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

Django

unread,
Feb 4, 2012, 6:09:39 PM2/4/12
to django-...@googlegroups.com
#17631: edge case: django.test.client should handle fields and files with the same
name
-------------------------------+------------------------------------
Reporter: dnozay | Owner: lrekucki
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.3
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 lrekucki):

* owner: nobody => lrekucki
* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted


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

Django

unread,
Feb 18, 2012, 4:51:39 AM2/18/12
to django-...@googlegroups.com
#17631: edge case: django.test.client should handle fields and files with the same
name
-------------------------------+------------------------------------
Reporter: dnozay | Owner:
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.3
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 lrekucki):

* owner: lrekucki =>


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

Django

unread,
May 12, 2012, 7:49:22 AM5/12/12
to django-...@googlegroups.com
#17631: edge case: django.test.client should handle fields and files with the same
name
-------------------------------+------------------------------------
Reporter: dnozay | Owner:
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.3
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 obeattie):

* cc: oliver@… (added)


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

Django

unread,
Mar 15, 2013, 3:53:33 AM3/15/13
to django-...@googlegroups.com
#17631: edge case: django.test.client should handle fields and files with the same
name
-----------------------------------+------------------------------------
Reporter: dnozay | Owner:
Type: Uncategorized | Status: new
Component: Testing framework | Version: 1.3

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 aaugustin):

* component: Uncategorized => Testing framework


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

Django

unread,
Mar 17, 2026, 12:52:03 PMMar 17
to django-...@googlegroups.com
#17631: edge case: django.test.client should handle fields and files with the same
name
-------------------------------------+-------------------------------------
Reporter: Damien Nozay | Owner: Anurag
Type: | Verma
Cleanup/optimization | Status: assigned
Component: Testing framework | Version: 1.3
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Anurag Verma):

* has_patch: 0 => 1
* owner: (none) => Anurag Verma
* status: new => assigned

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

Django

unread,
Jun 15, 2026, 3:55:16 AM (12 days ago) Jun 15
to django-...@googlegroups.com
#17631: edge case: django.test.client should handle fields and files with the same
name
-------------------------------------+-------------------------------------
Reporter: Damien Nozay | Owner: Anurag
Type: | Verma
Cleanup/optimization | Status: assigned
Component: Testing framework | Version: 1.3
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
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* needs_better_patch: 0 => 1

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

Django

unread,
Jun 16, 2026, 2:37:25 AM (11 days ago) Jun 16
to django-...@googlegroups.com
#17631: edge case: django.test.client should handle fields and files with the same
name
-------------------------------------+-------------------------------------
Reporter: Damien Nozay | Owner: Anurag
Type: | Verma
Cleanup/optimization | Status: assigned
Component: Testing framework | Version: 1.3
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/17631#comment:8>
Reply all
Reply to author
Forward
0 new messages