diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2007-05-07 12:34:18 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2007-05-07 12:34:18 +0000 |
| commit | f073797f4ca8d3e2736d99f76674e43640399c0d (patch) | |
| tree | 7d4b48a295dd516ddc2eef9db6f93b052a083ab4 /docs/testing.txt | |
| parent | 64adc413770c4762da5db697c4a332ac749cf4f3 (diff) | |
Added assertFormError, assertTemplateUsed and assertTemplateNotUsed for use during unit testing.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5156 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/testing.txt')
| -rw-r--r-- | docs/testing.txt | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/docs/testing.txt b/docs/testing.txt index 6cb763a85d..b3b33e9678 100644 --- a/docs/testing.txt +++ b/docs/testing.txt @@ -462,15 +462,36 @@ 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. -``assertRedirects(response, expected_path)`` - Assert that the response received redirects the browser to the provided - path, and that the expected_path can be retrieved. - ``assertContains(response, text, count=1)`` - Assert that a response indicates that a page was retreived successfully, + Assert that a response indicates that a page was retrieved successfully, (i.e., the HTTP status code was 200), and that ``text`` occurs ``count`` times in the content of the response. +``assertFormError(response, form, field, errors)`` + Assert that a field on a form raised the provided list of errors when + rendered on the form. + + ``form`` is the name the form object was given in the template context. + + ``field`` is the name of the field on the form to check. If ``field`` + has a value of ``None``, non-field errors will be checked. + + ``errors`` is an error string, or a list of error strings, that are + expected as a result of form validation. + +``assertTemplateNotUsed(response, template_name)`` + 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. + +``assertTemplateUsed(response, template_name)`` + Assert that the template with the given name was used in rendering the + response. + + Running tests ============= |
