summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-06-07 12:51:48 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-06-07 12:51:48 +0200
commit875c76251710c9b643a4e6164b5570713fe024f5 (patch)
tree794f780d90b73a00030f0a3eb6779db2f51d8526 /docs
parent17f3e9258e6050c274a7294213bd08bb71f2d2da (diff)
Fixed #16916 -- Documented default headers for the test client.
Thanks sailorfred AT yahoo.com for the report and raulcd for the initial version of the patch.
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/testing.txt21
1 files changed, 16 insertions, 5 deletions
diff --git a/docs/topics/testing.txt b/docs/topics/testing.txt
index f35c545c30..3d9504d193 100644
--- a/docs/topics/testing.txt
+++ b/docs/topics/testing.txt
@@ -650,8 +650,6 @@ Note a few important things about how the test client works:
* By default, the test client will disable any CSRF checks
performed by your site.
- .. versionadded:: 1.2.2
-
If, for some reason, you *want* the test client to perform CSRF
checks, you can create an instance of the test client that
enforces CSRF checks. To do this, pass in the
@@ -664,10 +662,23 @@ Note a few important things about how the test client works:
Making requests
~~~~~~~~~~~~~~~
-Use the ``django.test.client.Client`` class to make requests. It requires no
-arguments at time of construction:
+Use the ``django.test.client.Client`` class to make requests.
+
+.. class:: Client(enforce_csrf_checks=False, **defaults)
+
+ It requires no arguments at time of construction. However, you can use
+ keywords arguments to specify some default headers. For example, this will
+ send a ``User-Agent`` HTTP header in each request::
+
+ >>> c = Client(HTTP_USER_AGENT='Mozilla/5.0')
+
+ The values from the ``extra`` keywords arguments passed to
+ :meth:`~django.test.client.Client.get()`,
+ :meth:`~django.test.client.Client.post()`, etc. have precedence over
+ the defaults passed to the class constructor.
-.. class:: Client()
+ The ``enforce_csrf_checks`` argument can be used to test CSRF
+ protection (see above).
Once you have a ``Client`` instance, you can call any of the following
methods: