Opened 10 years ago

Closed 10 years ago

#22963 closed Bug (invalid)

Test client PATCH turns into GET when follow=True

Reported by: marshall@… Owned by: nobody
Component: Testing framework Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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

Attachments (1)

ticket_22963.zip (9.2 KB ) - added by Simon Charette 10 years ago.
Test project

Download all attachments as: .zip

Change History (2)

by Simon Charette, 10 years ago

Attachment: ticket_22963.zip added

Test project

comment:1 by Simon Charette, 10 years ago

Resolution: invalid
Status: newclosed

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

Note: See TracTickets for help on using tickets.
Back to Top