mirror of
https://github.com/django/django.git
synced 2025-10-26 07:06:08 +00:00
Fixed #15826 -- Made assertContains and assertNotContains work with SimpleTemplateResponse by forcing it to be rendered if it hasn't been rendered yet. Thanks to bmihelac for the report, to mmcnickle for the initial patch and tests, and to Carl Meyer for the guidance.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17025 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -500,6 +500,13 @@ class TransactionTestCase(SimpleTestCase):
|
||||
If ``count`` is None, the count doesn't matter - the assertion is true
|
||||
if the text occurs at least once in the response.
|
||||
"""
|
||||
|
||||
# If the response supports deferred rendering and hasn't been rendered
|
||||
# yet, then ensure that it does get rendered before proceeding further.
|
||||
if (hasattr(response, 'render') and callable(response.render)
|
||||
and not response.is_rendered):
|
||||
response.render()
|
||||
|
||||
if msg_prefix:
|
||||
msg_prefix += ": "
|
||||
|
||||
@@ -523,6 +530,13 @@ class TransactionTestCase(SimpleTestCase):
|
||||
successfully, (i.e., the HTTP status code was as expected), and that
|
||||
``text`` doesn't occurs in the content of the response.
|
||||
"""
|
||||
|
||||
# If the response supports deferred rendering and hasn't been rendered
|
||||
# yet, then ensure that it does get rendered before proceeding further.
|
||||
if (hasattr(response, 'render') and callable(response.render)
|
||||
and not response.is_rendered):
|
||||
response.render()
|
||||
|
||||
if msg_prefix:
|
||||
msg_prefix += ": "
|
||||
|
||||
|
||||
Reference in New Issue
Block a user