Created
January 19, 2013 23:44
-
-
Save niwinz/4575855 to your computer and use it in GitHub Desktop.
Support for patch method to django client.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.test import client | |
# Call this function on head of your test file. | |
def patch_request_factory(): | |
def _method(self, path, data='', content_type='application/octet-stream', follow=False, **extra): | |
response = self.generic("PATCH", path, data, content_type, **extra) | |
if follow: | |
response = self._handle_redirects(response, **extra) | |
return response | |
if not hasattr(client, "_patched"): | |
client._patched = True | |
client.Client.patch = _method | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a good solution for
django >= 1.5
.self.generic
doesn't exist indjango <=1.4
. So this throws an error. An alternative that works is this