1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #20237 (again) Allowed binary parameter to assertContains

This commit is contained in:
Claude Paroz
2013-04-12 20:00:49 +02:00
parent 8fc68af9c0
commit b04fd579d5
2 changed files with 18 additions and 7 deletions

View File

@@ -133,10 +133,15 @@ class AssertContainsTests(TestCase):
def test_binary_contains(self):
r = self.client.get('/test_client_regress/check_binary/')
self.assertContains(r, b'PDF document')
self.assertContains(r, b'%PDF-1.4\r\n%\x93\x8c\x8b\x9e')
with self.assertRaises(AssertionError):
self.assertContains(r, b'PDF document', count=2)
self.assertNotContains(r, b'ODF document')
self.assertContains(r, b'%PDF-1.4\r\n%\x93\x8c\x8b\x9e', count=2)
def test_binary_not_contains(self):
r = self.client.get('/test_client_regress/check_binary/')
self.assertNotContains(r, b'%ODF-1.4\r\n%\x93\x8c\x8b\x9e')
with self.assertRaises(AssertionError):
self.assertNotContains(r, b'%PDF-1.4\r\n%\x93\x8c\x8b\x9e')
def test_nontext_contains(self):
r = self.client.get('/test_client_regress/no_template_view/')