diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2007-05-10 11:27:59 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2007-05-10 11:27:59 +0000 |
| commit | 5c68ab6e2902b3cf67456d080c5314d3696d43e8 (patch) | |
| tree | 42cd5f75c85da51791fa8bfafd8ff41e80911b47 /docs | |
| parent | 606f387f4942ccb76a79eecd5b9c946f6455e219 (diff) | |
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
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/testing.txt | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/docs/testing.txt b/docs/testing.txt index ba13dab67e..b44b67c20a 100644 --- a/docs/testing.txt +++ b/docs/testing.txt @@ -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 |
