Code

Ticket #16916: 16916.diff

File 16916.diff, 1.6 KB (added by raulcd, 3 years ago)

First patch

Line 
1diff --git a/docs/topics/testing.txt b/docs/topics/testing.txt
2index f4c06e5..602d2e8 100644
3--- a/docs/topics/testing.txt
4+++ b/docs/topics/testing.txt
5@@ -664,13 +664,35 @@ Note a few important things about how the test client works:
6 Making requests
7 ~~~~~~~~~~~~~~~
8 
9-Use the ``django.test.client.Client`` class to make requests. It requires no
10-arguments at time of construction:
11+Use the ``django.test.client.Client`` class to make requests.
12 
13 .. class:: Client()
14 
15-    Once you have a ``Client`` instance, you can call any of the following
16-    methods:
17+    It requires no arguments at time of construction but you can provide some
18+    default values:
19+
20+    .. method:: Client.__init__(enforce_csrf_checks=False, **defaults)
21+
22+
23+        Creates an instance of the test client. By default the test client
24+        will disable any CSRF checks performed by your site due to the default
25+        ``enforce_csrf_checks`` value.
26+
27+        The ``defaults`` keywords argument parameter can be used to specify
28+        some default headers to be sent in the request. For example::
29+
30+            >>> c = Client(HTTP_USER_AGENT='Mozilla/5.0')
31+
32+        ...will send the HTTP header ``HTTP_USER_AGENT`` on further requests.
33+
34+        The values from the ``extra`` keywords argument on the
35+        :meth:`django.test.client.Client.get()`,
36+        :meth:`django.test.client.Client.post()`,
37+        :meth:`django.test.client.Client.delete()`
38+        , etc. have precedence than those defaults provided.
39+
40+        Once you have a ``Client`` instance, you can call any of the following
41+        methods:
42 
43     .. method:: Client.get(path, data={}, follow=False, **extra)
44