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

Fixed #10183 -- Corrected the handling of unicode in assertContains and assertNotContains. Thanks to trbs for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10414 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee
2009-04-07 12:06:05 +00:00
parent 37c21ef05d
commit 366710e636
5 changed files with 36 additions and 2 deletions

View File

@@ -12,6 +12,7 @@ from django.http import QueryDict
from django.test import _doctest as doctest
from django.test.client import Client
from django.utils import simplejson
from django.utils.encoding import smart_str
normalize_long_ints = lambda s: re.sub(r'(?<![\w])(\d+)L(?![\w])', '\\1', s)
normalize_decimals = lambda s: re.sub(r"Decimal\('(\d+(\.\d*)?)'\)", lambda m: "Decimal(\"%s\")" % m.groups()[0], s)
@@ -330,6 +331,7 @@ class TransactionTestCase(unittest.TestCase):
self.assertEqual(response.status_code, status_code,
"Couldn't retrieve page: Response code was %d (expected %d)'" %
(response.status_code, status_code))
text = smart_str(text, response._charset)
real_count = response.content.count(text)
if count is not None:
self.assertEqual(real_count, count,
@@ -348,8 +350,9 @@ class TransactionTestCase(unittest.TestCase):
self.assertEqual(response.status_code, status_code,
"Couldn't retrieve page: Response code was %d (expected %d)'" %
(response.status_code, status_code))
self.assertEqual(response.content.count(text), 0,
"Response should not contain '%s'" % text)
text = smart_str(text, response._charset)
self.assertEqual(response.content.count(text),
0, "Response should not contain '%s'" % text)
def assertFormError(self, response, form, field, errors):
"""