summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorJulien Phalip <jphalip@gmail.com>2011-10-22 09:15:50 +0000
committerJulien Phalip <jphalip@gmail.com>2011-10-22 09:15:50 +0000
commit4f00a2d316d6a8ffb6ca4ab6c89aaf8fb8bd3e60 (patch)
tree675ebfd94f11db6ea2daafbca4eedb37ea47d712 /django
parentac88f048c909de17e57414e35bd4e8f2fa2c17c2 (diff)
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
Diffstat (limited to 'django')
-rw-r--r--django/test/testcases.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/django/test/testcases.py b/django/test/testcases.py
index 010850d42a..ee22ac219e 100644
--- a/django/test/testcases.py
+++ b/django/test/testcases.py
@@ -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 += ": "