Ticket #3160: test_client_raw_post.patch

File test_client_raw_post.patch, 941 bytes (added by afternoon@…, 18 years ago)

[patch] Add raw_post method to django.test.client.Client

  • django/test/client.py

     
    176187
    177188        return self.request(**r)
    178189
     190    def raw_post(self, path, data="", type="application/x-www-url-encoded",
     191            **extra):
     192        """
     193        Request a response from the server using POST. Raw post data and a
     194        content type argument are supplied and passed unmodified.
     195        """
     196        r = {
     197            'CONTENT_LENGTH': len(data),
     198            'CONTENT_TYPE':   type,
     199            'PATH_INFO':      path,
     200            'REQUEST_METHOD': 'POST',
     201            'wsgi.input':     StringIO(data),
     202        }
     203        r.update(extra)
     204
     205        return self.request(**r)
     206
    179207    def login(self, path, username, password, **extra):
    180208        """
    181209        A specialized sequence of GET and POST to log into a view that
Back to Top