mirror of
https://github.com/django/django.git
synced 2025-07-18 08:39:15 +00:00
[1.0.X] Fixed #9607 -- Added documentation for the `extra
` argument in test client methods. Thanks to jroes for the report and patch.
Merge of r11173 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@11174 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
40f24b4635
commit
7b5869e140
@ -479,7 +479,7 @@ arguments at time of construction:
|
|||||||
Once you have a ``Client`` instance, you can call any of the following
|
Once you have a ``Client`` instance, you can call any of the following
|
||||||
methods:
|
methods:
|
||||||
|
|
||||||
.. method:: Client.get(path, data={})
|
.. method:: Client.get(path, data={}, **extra)
|
||||||
|
|
||||||
Makes a GET request on the provided ``path`` and returns a ``Response``
|
Makes a GET request on the provided ``path`` and returns a ``Response``
|
||||||
object, which is documented below.
|
object, which is documented below.
|
||||||
@ -494,7 +494,18 @@ arguments at time of construction:
|
|||||||
|
|
||||||
/customers/details/?name=fred&age=7
|
/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
|
Makes a POST request on the provided ``path`` and returns a
|
||||||
``Response`` object, which is documented below.
|
``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
|
Note that you should manually close the file after it has been provided
|
||||||
to ``post()``.
|
to ``post()``.
|
||||||
|
|
||||||
|
The ``extra`` argument acts the same as for :meth:`Client.get`.
|
||||||
|
|
||||||
.. method:: Client.login(**credentials)
|
.. method:: Client.login(**credentials)
|
||||||
|
|
||||||
.. versionadded:: 1.0
|
.. versionadded:: 1.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user