1
0
mirror of https://github.com/django/django.git synced 2024-12-23 09:36:06 +00:00

Fixed #9607 -- Added documentation for the `extra` argument in test 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
This commit is contained in:
Russell Keith-Magee 2009-07-03 07:40:45 +00:00
parent 5cef76ffb7
commit 87285078f0

View File

@ -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``
@ -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
@ -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.
@ -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
@ -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
@ -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
@ -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
@ -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
@ -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