Ticket #10183: assertContainsPatch.diff

File assertContainsPatch.diff, 1.5 KB (added by drakonen, 16 years ago)
  • django/test/testcases.py

    diff -r e3121a534d7b 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))
    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        self.assertEqual(response.content.count(smart_str(text)), 0,
    329330                         "Response should not contain '%s'" % text)
    330331
    331332    def assertFormError(self, response, form, field, errors):
Back to Top