diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2009-04-07 12:06:05 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2009-04-07 12:06:05 +0000 |
| commit | 366710e6368fbb7530ccfae92a2b6faa40ea4bc1 (patch) | |
| tree | 007a89f3096ad5ea6cd7fee58f818c5f60d50940 /django/test/testcases.py | |
| parent | 37c21ef05d678d09a1143c3699c2165d0b8fa300 (diff) | |
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
Diffstat (limited to 'django/test/testcases.py')
| -rw-r--r-- | django/test/testcases.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/django/test/testcases.py b/django/test/testcases.py index 550baf9137..794bc5039d 100644 --- a/django/test/testcases.py +++ b/django/test/testcases.py @@ -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): """ |
