diff --git a/django/test/testcases.py b/django/test/testcases.py
index 5589443..8f76d6e 100644
a
|
b
|
class TestCase(unittest.TestCase):
|
128 | 128 | self.failUnless(real_count != 0, |
129 | 129 | "Couldn't find '%s' in response" % text) |
130 | 130 | |
| 131 | def assertNotContains(self, response, text, status_code=200): |
| 132 | """ |
| 133 | Asserts that a response indicates that a page was retrieved |
| 134 | successfully, (i.e., the HTTP status code was as expected), and that |
| 135 | ``text`` doesn't occurs in the content of the response. |
| 136 | """ |
| 137 | self.assertEqual(response.status_code, status_code, |
| 138 | "Couldn't retrieve page: Response code was %d (expected %d)'" % |
| 139 | (response.status_code, status_code)) |
| 140 | self.assertEqual(response.content.count(text), 0, |
| 141 | "Response should't have had '%s'" % text) |
| 142 | |
131 | 143 | def assertFormError(self, response, form, field, errors): |
132 | 144 | """ |
133 | 145 | Asserts that a form used to render the response has a specific field |
diff --git a/docs/testing.txt b/docs/testing.txt
index 0ff3cce..97f5ae4 100644
a
|
b
|
useful for testing Web applications:
|
822 | 822 | that ``text`` appears in the content of the response. If ``count`` is |
823 | 823 | provided, ``text`` must occur exactly ``count`` times in the response. |
824 | 824 | |
| 825 | ``assertNotContains(response, text, status_code=200)`` |
| 826 | Asserts that a ``Response`` instance produced the given ``status_code`` and |
| 827 | that ``text`` does not appears in the content of the response. |
| 828 | |
825 | 829 | ``assertFormError(response, form, field, errors)`` |
826 | 830 | Asserts that a field on a form raises the provided list of errors when |
827 | 831 | rendered on the form. |
diff --git a/tests/modeltests/test_client/models.py b/tests/modeltests/test_client/models.py
index f5b1988..bc664dd 100644
a
|
b
|
class ClientTest(TestCase):
|
406 | 406 | self.assertEqual(mail.outbox[1].to[0], 'second@example.com') |
407 | 407 | self.assertEqual(mail.outbox[1].to[1], 'third@example.com') |
408 | 408 | |
| 409 | def test_not_contains(self): |
| 410 | response = self.client.get('/test_client/get_view/') |
| 411 | self.assertNotContains(response, "surely not there") |
| 412 | self.assertRaises(AssertionError, |
| 413 | self.assertNotContains, response, "This is a test") |
| 414 | |