Ticket #10183: django.test.testcases_assertContainsPatch.2.diff

File django.test.testcases_assertContainsPatch.2.diff, 1.6 KB (added by trbs, 16 years ago)
  • django/test/testcases.py

    diff -r c652d05460a8 django/test/testcases.py
    a b  
    1212from django.test import _doctest as doctest
    1313from django.test.client import Client
    1414from django.utils import simplejson
     15from django.utils.encoding import smart_str
    1516
    1617normalize_long_ints = lambda s: re.sub(r'(?<![\w])(\d+)L(?![\w])', '\\1', s)
    1718normalize_decimals = lambda s: re.sub(r"Decimal\('(\d+(\.\d*)?)'\)", lambda m: "Decimal(\"%s\")" % m.groups()[0], s)
     
    307308        self.assertEqual(response.status_code, status_code,
    308309            "Couldn't retrieve page: Response code was %d (expected %d)'" %
    309310                (response.status_code, status_code))
    310         real_count = response.content.count(text)
     311        real_count = response.content.count(smart_str(text, response._charset))
    311312        if count is not None:
    312313            self.assertEqual(real_count, count,
    313314                "Found %d instances of '%s' in response (expected %d)" %
     
    325326        self.assertEqual(response.status_code, status_code,
    326327            "Couldn't retrieve page: Response code was %d (expected %d)'" %
    327328                (response.status_code, status_code))
    328         self.assertEqual(response.content.count(text), 0,
    329                         "Response should not contain '%s'" % text)
     329        self.assertEqual(response.content.count(smart_str(text, response._charset)),
     330             0, "Response should not contain '%s'" % text)
    330331
    331332    def assertFormError(self, response, form, field, errors):
    332333        """
Back to Top