diff options
| author | Honza Král <honza.kral@gmail.com> | 2009-07-15 07:19:10 +0000 |
|---|---|---|
| committer | Honza Král <honza.kral@gmail.com> | 2009-07-15 07:19:10 +0000 |
| commit | d0c3e19de5bf9d79f5436f8ddeccf9bea98d9306 (patch) | |
| tree | 5975afb05ef971945dd9afb9a977d5a59b04eaf4 /docs/topics/testing.txt | |
| parent | f662801023605ff6fe44416271e39839894e7962 (diff) | |
[soc2009/model-validation] Merget to trunk at r11229
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/model-validation@11233 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/topics/testing.txt')
| -rw-r--r-- | docs/topics/testing.txt | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/docs/topics/testing.txt b/docs/topics/testing.txt index 1256a61187..d235e0deba 100644 --- a/docs/topics/testing.txt +++ b/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 |
