Ticket #9607: add-extra-parameter-to-testing-doc.diff

File add-extra-parameter-to-testing-doc.diff, 2.8 KB (added by Jonathan Roes, 16 years ago)
  • docs/topics/testing.txt

     
    478478    Once you have a ``Client`` instance, you can call any of the following
    479479    methods:
    480480
    481     .. method:: Client.get(path, data={})
     481    .. method:: Client.get(path, data={}, **extra)
    482482
    483483        Makes a GET request on the provided ``path`` and returns a ``Response``
    484484        object, which is documented below.
     
    493493
    494494            /customers/details/?name=fred&age=7
    495495
     496        The ``extra`` keyword arguments parameter can be used to specify
     497        headers to be sent in the request. For example::
     498       
     499            >>> c = Client()
     500            >>> c.get('/customers/details/', {'name': 'fred', 'age': 7},
     501            ...       HTTP_X_REQUESTED_WITH='XMLHttpRequest')
     502
     503        ...this will send the HTTP header ``HTTP_X_REQUESTED_WITH`` to the
     504        details view, which is a good way to test code paths that use the
     505        :meth:`django.http.HttpRequest.is_ajax()` method.
     506
    496507        .. versionadded:: development
    497508
    498509        If you already have the GET arguments in URL-encoded form, you can
     
    505516        If you provide URL both an encoded GET data and a data argument,
    506517        the data argument will take precedence.
    507518
    508     .. method:: Client.post(path, data={}, content_type=MULTIPART_CONTENT)
     519    .. method:: Client.post(path, data={}, content_type=MULTIPART_CONTENT, **extra)
    509520
    510521        Makes a POST request on the provided ``path`` and returns a
    511522        ``Response`` object, which is documented below.
     
    568579        to retrieve the username and password, and could interrogate request.GET
    569580        to determine if the user was a visitor.
    570581
    571     .. method:: Client.head(path, data={})
     582    .. method:: Client.head(path, data={}, **extra)
    572583
    573584        .. versionadded:: development
    574585
     
    576587        object. Useful for testing RESTful interfaces. Acts just like
    577588        :meth:`Client.get` except it does not return a message body.
    578589
    579     .. method:: Client.options(path, data={})
     590    .. method:: Client.options(path, data={}, **extra)
    580591
    581592        .. versionadded:: development
    582593
    583594        Makes an OPTIONS request on the provided ``path`` and returns a
    584595        ``Response`` object. Useful for testing RESTful interfaces.
    585596
    586     .. method:: Client.put(path, data={}, content_type=MULTIPART_CONTENT)
     597    .. method:: Client.put(path, data={}, content_type=MULTIPART_CONTENT, **extra)
    587598
    588599        .. versionadded:: development
    589600
     
    591602        ``Response`` object. Useful for testing RESTful interfaces. Acts just
    592603        like :meth:`Client.post` except with the PUT request method.
    593604
    594     .. method:: Client.delete(path)
     605    .. method:: Client.delete(path, **extra)
    595606
    596607        .. versionadded:: development
    597608
Back to Top