mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +00:00
Added configurable arguments to assertRedirects and assertContains to allow for other response status codes. Thanks for the suggestion, Jiri Barton.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5179 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
606f387f49
commit
5c68ab6e29
5 changed files with 59 additions and 20 deletions
|
@ -472,9 +472,9 @@ Normal Python unit tests have a wide range of assertions, such as
|
|||
``django.TestCase`` adds to these, providing some assertions
|
||||
that can be useful in testing the behavior of web sites.
|
||||
|
||||
``assertContains(response, text, count=1)``
|
||||
Assert that a response indicates that a page was retrieved successfully,
|
||||
(i.e., the HTTP status code was 200), and that ``text`` occurs ``count``
|
||||
``assertContains(response, text, count=1, status_code=200)``
|
||||
Assert that a response indicates that a page could be retrieved and
|
||||
produced the nominated status code, and that ``text`` occurs ``count``
|
||||
times in the content of the response.
|
||||
|
||||
``assertFormError(response, form, field, errors)``
|
||||
|
@ -493,9 +493,10 @@ that can be useful in testing the behavior of web sites.
|
|||
Assert that the template with the given name was *not* used in rendering
|
||||
the response.
|
||||
|
||||
``assertRedirects(response, expected_path)``
|
||||
Assert that the response received redirects the browser to the provided
|
||||
path, and that the expected_path can be retrieved.
|
||||
``assertRedirects(response, expected_path, status_code=302, target_status_code=200)``
|
||||
Assert that the response received produced the nominated status code,
|
||||
redirects the browser to the provided path, and that retrieving the provided
|
||||
path yields a response with the target status code.
|
||||
|
||||
``assertTemplateUsed(response, template_name)``
|
||||
Assert that the template with the given name was used in rendering the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue