﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33757	django.test.Client.post documentation is wrong	bastian-wattro	nobody	"Following [https://docs.djangoproject.com/en/4.0/topics/testing/tools/#django.test.Client.post]
with Django version 4.0.4 to write my first unit tests, I failed to upload a file.

As described there, I tried
{{{#!python
with open('mal.csv', 'rb') as fp:
  self.client.post('/post/endpoint/', {'name': 'fred', 'attachment': fp})
}}}
And assumed that (as described there) 
> The name attachment here is not relevant; use whatever name your file-processing code expects.

This made the test fail. Printing request.FILES returned:
`<MultiValueDict: {'attachment': [<InMemoryUploadedFile: mal.csv (text/csv)>]}>`

What worked was the (way more intuitive)
{{{#!python
with open('mal.csv', 'rb') as fp:
  self.client.post('/post/entpoint/', {'name': 'fred', 'attachment': fp})
# <MultiValueDict: {'fred': [<InMemoryUploadedFile: mal.csv (text/csv)>]}>
}}}

I did not check:
*  since when the documentation is obsolete
* if this is intended behavior"	Bug	new	Documentation	4.0	Normal				Unreviewed	0	0	0	0	0	0
