Skip to content

Commit

Permalink
Fixed #9607 -- Added documentation for the extra argument in test…
Browse files Browse the repository at this point in the history
… client methods. Thanks to jroes for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@11173 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
freakboy3742 committed Jul 3, 2009
1 parent 5cef76f commit 8728507
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions docs/topics/testing.txt
Expand Up @@ -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={}, follow=False)
.. method:: Client.get(path, data={}, follow=False, **extra)


Makes a GET request on the provided ``path`` and returns a ``Response``
Expand All @@ -495,6 +495,17 @@ arguments at time of construction:

/customers/details/?name=fred&age=7

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.

.. versionadded:: 1.1

If you already have the GET arguments in URL-encoded form, you can
Expand All @@ -518,7 +529,7 @@ arguments at time of construction:
>>> response.redirect_chain
[(u'http://testserver/next/', 302), (u'http://testserver/final/', 302)]

.. method:: Client.post(path, data={}, content_type=MULTIPART_CONTENT, follow=False)
.. method:: Client.post(path, data={}, content_type=MULTIPART_CONTENT, follow=False, **extra)

Makes a POST request on the provided ``path`` and returns a
``Response`` object, which is documented below.
Expand Down Expand Up @@ -569,6 +580,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`.

.. versionchanged:: 1.1

If the URL you request with a POST contains encoded parameters, these
Expand All @@ -585,7 +598,7 @@ arguments at time of construction:
and a ``redirect_chain`` attribute will be set in the response object
containing tuples of the intermediate urls and status codes.

.. method:: Client.head(path, data={}, follow=False)
.. method:: Client.head(path, data={}, follow=False, **extra)

.. versionadded:: 1.1

Expand All @@ -597,7 +610,7 @@ arguments at time of construction:
and a ``redirect_chain`` attribute will be set in the response object
containing tuples of the intermediate urls and status codes.

.. method:: Client.options(path, data={}, follow=False)
.. method:: Client.options(path, data={}, follow=False, **extra)

.. versionadded:: 1.1

Expand All @@ -608,7 +621,9 @@ arguments at time of construction:
and a ``redirect_chain`` attribute will be set in the response object
containing tuples of the intermediate urls and status codes.

.. method:: Client.put(path, data={}, content_type=MULTIPART_CONTENT, follow=False)
The ``extra`` argument acts the same as for :meth:`Client.get`.

.. method:: Client.put(path, data={}, content_type=MULTIPART_CONTENT, follow=False, **extra)

.. versionadded:: 1.1

Expand All @@ -620,7 +635,7 @@ arguments at time of construction:
and a ``redirect_chain`` attribute will be set in the response object
containing tuples of the intermediate urls and status codes.

.. method:: Client.delete(path, follow=False)
.. method:: Client.delete(path, follow=False, **extra)

.. versionadded:: 1.1

Expand All @@ -631,6 +646,8 @@ arguments at time of construction:
and a ``redirect_chain`` attribute will be set in the response object
containing tuples of the intermediate urls and status codes.

The ``extra`` argument acts the same as for :meth:`Client.get`.

.. method:: Client.login(**credentials)

.. versionadded:: 1.0
Expand Down

0 comments on commit 8728507

Please sign in to comment.