Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion AUTHORS
Expand Up @@ -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>
Expand Down
26 changes: 24 additions & 2 deletions docs/topics/testing.txt
Expand Up @@ -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:

Expand Down