summaryrefslogtreecommitdiff
path: root/docs/topics/testing.txt
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2010-01-22 15:02:02 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2010-01-22 15:02:02 +0000
commit7ca9d9306c5e5e175668af513725a16ba3b26d9d (patch)
treed55c30d0ccf880c75ab28c1736d4c39f6477572c /docs/topics/testing.txt
parent1b3dc8ad9a28486542f766ff93318aa6b4f5999b (diff)
Fixed #10314 -- Added a message prefix argument to Django's test assertions. Thanks to Wes Winham for the original suggestion, and Chistian Oudard for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12273 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/topics/testing.txt')
-rw-r--r--docs/topics/testing.txt21
1 files changed, 15 insertions, 6 deletions
diff --git a/docs/topics/testing.txt b/docs/topics/testing.txt
index 0b205cee35..b515d2fac9 100644
--- a/docs/topics/testing.txt
+++ b/docs/topics/testing.txt
@@ -1104,23 +1104,32 @@ Assertions
.. versionadded:: 1.0
+.. versionchanged:: 1.2
+ Addded ``msg_prefix`` argument.
+
As Python's normal ``unittest.TestCase`` class implements assertion methods
such as ``assertTrue`` and ``assertEquals``, Django's custom ``TestCase`` class
provides a number of custom assertion methods that are useful for testing Web
applications:
-.. method:: TestCase.assertContains(response, text, count=None, status_code=200)
+The failure messages given by the assertion methods can be customized
+with the ``msg_prefix`` argument. This string will be prefixed to any
+failure message generated by the assertion. This allows you to provide
+additional details that may help you to identify the location and
+cause of an failure in your test suite.
+
+.. method:: TestCase.assertContains(response, text, count=None, status_code=200, msg_prefix='')
Asserts that a ``Response`` instance produced the given ``status_code`` and
that ``text`` appears in the content of the response. If ``count`` is
provided, ``text`` must occur exactly ``count`` times in the response.
-.. method:: TestCase.assertNotContains(response, text, status_code=200)
+.. method:: TestCase.assertNotContains(response, text, status_code=200, msg_prefix='')
Asserts that a ``Response`` instance produced the given ``status_code`` and
that ``text`` does not appears in the content of the response.
-.. method:: TestCase.assertFormError(response, form, field, errors)
+.. method:: TestCase.assertFormError(response, form, field, errors, msg_prefix='')
Asserts that a field on a form raises the provided list of errors when
rendered on the form.
@@ -1135,19 +1144,19 @@ applications:
``errors`` is an error string, or a list of error strings, that are
expected as a result of form validation.
-.. method:: TestCase.assertTemplateUsed(response, template_name)
+.. method:: TestCase.assertTemplateUsed(response, template_name, msg_prefix='')
Asserts that the template with the given name was used in rendering the
response.
The name is a string such as ``'admin/index.html'``.
-.. method:: TestCase.assertTemplateNotUsed(response, template_name)
+.. method:: TestCase.assertTemplateNotUsed(response, template_name, msg_prefix='')
Asserts that the template with the given name was *not* used in rendering
the response.
-.. method:: TestCase.assertRedirects(response, expected_url, status_code=302, target_status_code=200)
+.. method:: TestCase.assertRedirects(response, expected_url, status_code=302, target_status_code=200, msg_prefix='')
Asserts that the response return a ``status_code`` redirect status, it
redirected to ``expected_url`` (including any GET data), and the final