Django

Code

Ticket #11786 (closed: duplicate)

Opened 7 months ago

Last modified 7 months ago

TestClient() forgets any PUT querystrings if there is payload data

Reported by: steve@stevejalim.co.uk Assigned to: nobody
Milestone: Component: Testing framework
Version: 1.1 Keywords: PUT
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

Hi

On line 370 of contrib.test.client.py there is the following line in the put() method:

'QUERY_STRING': urlencode(data, doseq=True) or parsed[4],

(by comparison, post() has:

'QUERY_STRING': parsed[4],

As a a result of the way the code is in put(), if there is a querystring (eg user_token=foo123) and also payload data with the PUT { foo:'12' } , the querystring is overwritten with the payload data.

Now, I'm not 100% whether PUT can take querystrings and payload data at the same time, but if it is supposed to, how about instead we have line 370 as:

'QUERY_STRING': parsed[4] or urlencode(data, doseq=True),

Which seems to work fine (ie, my app's tests now pass)

Attachments

Change History

08/26/09 10:29:21 changed by kmtracey

  • status changed from new to closed.
  • needs_better_patch changed.
  • resolution set to duplicate.
  • needs_tests changed.
  • needs_docs changed.

#11371 looks like the same issue.


Add/Change #11786 (TestClient() forgets any PUT querystrings if there is payload data)




Change Properties
Action