Fixed #18980 -- Fixed assertContains regression when passed an object
This commit is contained in:
parent
319e135519
commit
40e62a5ccd
|
@ -647,6 +647,7 @@ class TransactionTestCase(SimpleTestCase):
|
|||
self.assertEqual(response.status_code, status_code,
|
||||
msg_prefix + "Couldn't retrieve content: Response code was %d"
|
||||
" (expected %d)" % (response.status_code, status_code))
|
||||
text = force_text(text, encoding=response._charset)
|
||||
content = response.content.decode(response._charset)
|
||||
if html:
|
||||
content = assert_and_parse_html(self, content, None,
|
||||
|
@ -682,6 +683,7 @@ class TransactionTestCase(SimpleTestCase):
|
|||
self.assertEqual(response.status_code, status_code,
|
||||
msg_prefix + "Couldn't retrieve content: Response code was %d"
|
||||
" (expected %d)" % (response.status_code, status_code))
|
||||
text = force_text(text, encoding=response._charset)
|
||||
content = response.content.decode(response._charset)
|
||||
if html:
|
||||
content = assert_and_parse_html(self, content, None,
|
||||
|
|
|
@ -16,6 +16,7 @@ from django.test import Client, TestCase
|
|||
from django.test.client import encode_file, RequestFactory
|
||||
from django.test.utils import ContextList, override_settings, str_prefix
|
||||
from django.template.response import SimpleTemplateResponse
|
||||
from django.utils.translation import ugettext_lazy
|
||||
from django.http import HttpResponse
|
||||
|
||||
|
||||
|
@ -129,6 +130,14 @@ class AssertContainsTests(TestCase):
|
|||
self.assertNotContains(r, 'はたけ')
|
||||
self.assertNotContains(r, b'\xe3\x81\xaf\xe3\x81\x9f\xe3\x81\x91'.decode('utf-8'))
|
||||
|
||||
def test_nontext_contains(self):
|
||||
r = self.client.get('/test_client_regress/no_template_view/')
|
||||
self.assertContains(r, ugettext_lazy('once'))
|
||||
|
||||
def test_nontext_not_contains(self):
|
||||
r = self.client.get('/test_client_regress/no_template_view/')
|
||||
self.assertNotContains(r, ugettext_lazy('never'))
|
||||
|
||||
def test_assert_contains_renders_template_response(self):
|
||||
""" Test that we can pass in an unrendered SimpleTemplateReponse
|
||||
without throwing an error.
|
||||
|
|
Loading…
Reference in New Issue