Opened 18 years ago

Closed 17 years ago

#2860 closed defect (wontfix)

Test client only supports file uploads with foo and foo_file parameters

Reported by: dave AT avaragado.org Owned by: nobody
Component: Testing framework Version: dev
Severity: normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I'm using a custom manipulator with an ImageUploadField instance. This means I don't use the foo and foo_file system documented at http://www.djangoproject.com/documentation/forms/#filefield-and-imagefield-special-cases - my field is called foo, and that's the name of the form field output in the HTML, and the name of the parameter on the network.

Unfortunately, the test client doesn't appear to support this scenario. With code like this:

f = open('/my/test/file')
c.post('/foo/bar/', { 'foo': f })
f.close()

the test client transmogrifies my foo parameter into both foo and foo_file, with foo the empty string and foo_file the uploaded file itself. Sadly this is not what my manipulator is expecting, and hilarity ensues.

There's a simple workaround in the manipulator: overwrite foo with foo_file, if present. Shame it's needed though, as it's a hack to make the tests pass.

Change History (3)

comment:1 by Russell Keith-Magee, 18 years ago

Owner: changed from Adrian Holovaty to Russell Keith-Magee

comment:2 by Simon G. <dev@…>, 17 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Russell Keith-Magee, 17 years ago

Resolution: wontfix
Status: newclosed

This is no longer a problem with newforms and the new FileField and ImageField.

Note: See TracTickets for help on using tickets.
Back to Top