[Django] #22963: Test client PATCH turns into GET when follow=True

12 views
Skip to first unread message

Django

unread,
Jul 5, 2014, 4:37:05 PM7/5/14
to django-...@googlegroups.com
#22963: Test client PATCH turns into GET when follow=True
-----------------------------------+--------------------
Reporter: marshall@… | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 1.6
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------
I ran into a little problem with the test framework. When following a
redirect the PATCH request magically turns into a GET.
{{{
class DjangoTestPatch(TestCase):
def test_patch_follow_redirect(self):
response = self.client.patch('/path/')
self.assertEqual(response.request['REQUEST_METHOD'], 'PATCH')
#Works
response = self.client.patch('/path', follow=True)
self.assertEqual(response.request['REQUEST_METHOD'], 'PATCH')
#Doesn't Work
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22963>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 7, 2014, 2:20:46 AM7/7/14
to django-...@googlegroups.com
#22963: Test client PATCH turns into GET when follow=True
-----------------------------------+--------------------------------------
Reporter: marshall@… | Owner: nobody
Type: Bug | Status: closed

Component: Testing framework | Version: 1.6
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by charettes):

* status: new => closed
* needs_better_patch: => 0
* resolution: => invalid
* needs_tests: => 0
* needs_docs: => 0


Comment:

Hi Marshall,

This is the expected behavior of `follow=True` since the `request`
attribute of the `response` refers to the redirect request which is
performed using `GET` method.

You can test that this is not a `django.test.client.Client.patch`
peculiarity by performing a `POST` and observing the same behavior (given
that your `'/path/'` also performs a redirect for this method).

I'm attaching a test project I used to make sure your report was invalid.
If you need extra help with the test framework I suggest your refer to
wiki:TicketClosingReasons/UseSupportChannels before reporting a ticket.
You should get feedback faster this way.

Simon

--
Ticket URL: <https://code.djangoproject.com/ticket/22963#comment:1>

Reply all
Reply to author
Forward
0 new messages