Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[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
  • Loading branch information...
commit 7b5869e140379bb4a6525bc5e48a1dc069635d23 1 parent 40f24b4
@freakboy3742 freakboy3742 authored
Showing with 15 additions and 2 deletions.
  1. +15 −2 docs/topics/testing.txt
View
17 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
Please sign in to comment.
Something went wrong with that request. Please try again.