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 , 18 years ago
Owner: | changed from | to
---|
comment:2 by , 17 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 17 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
This is no longer a problem with newforms and the new FileField and ImageField.