Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit 87285078f08f3889cf273c4547022b81cec5733d 1 parent 5cef76f
@freakboy3742 freakboy3742 authored
Showing with 23 additions and 6 deletions.
  1. +23 −6 docs/topics/testing.txt
View
29 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={}, 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
Please sign in to comment.
Something went wrong with that request. Please try again.