Code

Opened 8 years ago

Closed 7 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: master
Severity: normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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.

Attachments (0)

Change History (3)

comment:1 Changed 8 years ago by russellm

  • Owner changed from adrian to russellm

comment:2 Changed 7 years ago by Simon G. <dev@…>

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 7 years ago by russellm

  • Resolution set to wontfix
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.