diff --git a/docs/topics/testing.txt b/docs/topics/testing.txt index d7820cbe46..f4f289ccd7 100644 --- a/docs/topics/testing.txt +++ b/docs/topics/testing.txt @@ -479,7 +479,7 @@ arguments at time of construction: Once you have a ``Client`` instance, you can call any of the following methods: - .. method:: Client.get(path, data={}) + .. method:: Client.get(path, data={}, **extra) Makes a GET request on the provided ``path`` and returns a ``Response`` object, which is documented below. @@ -494,7 +494,18 @@ arguments at time of construction: /customers/details/?name=fred&age=7 - .. method:: Client.post(path, data={}, content_type=MULTIPART_CONTENT) + The ``extra`` keyword arguments parameter can be used to specify + headers to be sent in the request. For example:: + + >>> c = Client() + >>> c.get('/customers/details/', {'name': 'fred', 'age': 7}, + ... HTTP_X_REQUESTED_WITH='XMLHttpRequest') + + ...will send the HTTP header ``HTTP_X_REQUESTED_WITH`` to the + details view, which is a good way to test code paths that use the + :meth:`django.http.HttpRequest.is_ajax()` method. + + .. method:: Client.post(path, data={}, content_type=MULTIPART_CONTENT, **extra) Makes a POST request on the provided ``path`` and returns a ``Response`` object, which is documented below. @@ -545,6 +556,8 @@ arguments at time of construction: Note that you should manually close the file after it has been provided to ``post()``. + The ``extra`` argument acts the same as for :meth:`Client.get`. + .. method:: Client.login(**credentials) .. versionadded:: 1.0