Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added to the documentation the django.test.Client.defaults definition. #115

Closed
wants to merge 3 commits into from

1 participant

Raúl Cumplido
Raúl Cumplido

No description provided.

Raúl Cumplido added some commits
Raúl Cumplido raulcd closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 7, 2012
  1. Fixed #16916 -- Documented django.test.Client.defaults. Added myself …

    Raúl Cumplido authored
    …to AUTHORS as it's the 5th patch I've submitted
  2. Merge remote-tracking branch 'upstream/master'

    Raúl Cumplido authored
  3. Fixed #16916 -- Documented django.test.Client.defaults. Added myself …

    Raúl Cumplido authored
    …to AUTHORS.
This page is out of date. Refresh to see the latest.
Showing with 26 additions and 3 deletions.
  1. +2 −1  AUTHORS
  2. +24 −2 docs/topics/testing.txt
3  AUTHORS
View
@@ -136,9 +136,10 @@ answer newbie questions, and generally made Django that much better:
Robert Coup
Pete Crosier <pete.crosier@gmail.com>
Matt Croydon <http://www.postneo.com/>
+ Jure Cuhalev <gandalf@owca.info>
Leah Culver <leah.culver@gmail.com>
+ Raúl Cumplido <raulcumplido@gmail.com>
flavio.curella@gmail.com
- Jure Cuhalev <gandalf@owca.info>
John D'Agostino <john.dagostino@gmail.com>
dackze+django@gmail.com
Jim Dalton <jim.dalton@gmail.com>
26 docs/topics/testing.txt
View
@@ -664,11 +664,33 @@ 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()
+ It requires no arguments at time of construction but you can provide some
+ default values:
+
+ .. method:: Client.__init__(enforce_csrf_checks=False, **defaults)
+
+ Creates an instance of the test client.
+
+ The ``defaults`` keywords argument parameter can be used to specify
+ some default headers to be sent in the request. For example::
+
+ >>> c = Client(HTTP_USER_AGENT='Mozilla/5.0')
+
+ ...will send the HTTP header ``HTTP_USER_AGENT`` on further requests.
+
+ The values from the ``extra`` keywords argument on the
+ :meth:`django.test.client.Client.get()`,
+ :meth:`django.test.client.Client.post()`,
+ :meth:`django.test.client.Client.delete()`
+ , etc. have precedence than those defaults provided.
+
+ By default the test client will disable any CSRF checks performed by
+ your site due to the default ``enforce_csrf_checks`` value.
+
Once you have a ``Client`` instance, you can call any of the following
methods:
Something went wrong with that request. Please try again.