Ticket #5682: patch_django_5682_client.diff

File patch_django_5682_client.diff, 1.6 KB (added by David Larlet, 17 years ago)

Need documentation on testing.txt

  • django_src/django/test/client.py

     
    218218
    219219        return self.request(**r)
    220220
     221    def delete(self, path, data={}, **extra):
     222        "Request a response from the server using DELETE."
     223        r = {
     224            'CONTENT_LENGTH':  None,
     225            'CONTENT_TYPE':    'text/html; charset=utf-8',
     226            'PATH_INFO':       path,
     227            'QUERY_STRING':    urlencode(data, doseq=True),
     228            'REQUEST_METHOD': 'DELETE',
     229        }
     230        r.update(extra)
     231
     232        return self.request(**r)
     233
    221234    def post(self, path, data={}, content_type=MULTIPART_CONTENT, **extra):
    222235        "Request a response from the server using POST."
    223236
     
    237250
    238251        return self.request(**r)
    239252
     253    def put(self, path, data={}, content_type=MULTIPART_CONTENT, **extra):
     254        "Request a response from the server using PUT."
     255
     256        if content_type is MULTIPART_CONTENT:
     257            put_data = encode_multipart(BOUNDARY, data)
     258        else:
     259            put_data = data
     260
     261        r = {
     262            'CONTENT_LENGTH': len(put_data),
     263            'CONTENT_TYPE':   content_type,
     264            'PATH_INFO':      path,
     265            'REQUEST_METHOD': 'PUT',
     266            'wsgi.input':     StringIO(put_data),
     267        }
     268        r.update(extra)
     269
     270        return self.request(**r)
     271
    240272    def login(self, **credentials):
    241273        """Set the Client to appear as if it has sucessfully logged into a site.
    242274
Back to Top