summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorJulien Phalip <jphalip@gmail.com>2013-02-02 18:22:40 -0800
committerJulien Phalip <jphalip@gmail.com>2013-02-02 18:22:40 -0800
commit293f7a21147ad94c92c7d5b3f33cbab2f87b001b (patch)
tree43e1539dbf406d29782c5fffe85db25a3945ac24 /django
parent08dc90bccf7c4ffa8b04064d74b54c1150af5ff9 (diff)
Fixed #17797 -- Enabled support for PATCH requests in the dummy test client. Thanks to pfarmer for the suggestion and initial patch.
Diffstat (limited to 'django')
-rw-r--r--django/test/client.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/django/test/client.py b/django/test/client.py
index 6bdc1cf3d3..bb0f25e108 100644
--- a/django/test/client.py
+++ b/django/test/client.py
@@ -319,6 +319,11 @@ class RequestFactory(object):
"Construct a PUT request."
return self.generic('PUT', path, data, content_type, **extra)
+ def patch(self, path, data='', content_type='application/octet-stream',
+ **extra):
+ "Construct a PATCH request."
+ return self.generic('PATCH', path, data, content_type, **extra)
+
def delete(self, path, data='', content_type='application/octet-stream',
**extra):
"Construct a DELETE request."
@@ -496,6 +501,17 @@ class Client(RequestFactory):
response = self._handle_redirects(response, **extra)
return response
+ def patch(self, path, data='', content_type='application/octet-stream',
+ follow=False, **extra):
+ """
+ Send a resource to the server using PATCH.
+ """
+ response = super(Client, self).patch(
+ path, data=data, content_type=content_type, **extra)
+ if follow:
+ response = self._handle_redirects(response, **extra)
+ return response
+
def delete(self, path, data='', content_type='application/octet-stream',
follow=False, **extra):
"""