summaryrefslogtreecommitdiff
path: root/tests/template_tests/syntax_tests/test_if_changed.py
diff options
context:
space:
mode:
authorPreston Timmons <prestontimmons@gmail.com>2015-04-11 19:41:45 -0400
committerPreston Timmons <prestontimmons@gmail.com>2015-04-20 09:11:37 -0500
commitfb267a1d85c22924231be8cec6c58c42ae57913f (patch)
treed85f9285bea1c37d7af83ebc5c84996d2e9d51dd /tests/template_tests/syntax_tests/test_if_changed.py
parentd84f01ff08922c70f9bb0861846c8ace0764b2dc (diff)
Updated template tests to create their own engine.
This continues work to treat Django templates as a library.
Diffstat (limited to 'tests/template_tests/syntax_tests/test_if_changed.py')
-rw-r--r--tests/template_tests/syntax_tests/test_if_changed.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/template_tests/syntax_tests/test_if_changed.py b/tests/template_tests/syntax_tests/test_if_changed.py
index b06c0bbdd9..62f9563020 100644
--- a/tests/template_tests/syntax_tests/test_if_changed.py
+++ b/tests/template_tests/syntax_tests/test_if_changed.py
@@ -1,4 +1,4 @@
-from django.template import Context, Template
+from django.template import Context, Engine
from django.test import SimpleTestCase
from ..utils import setup
@@ -157,11 +157,19 @@ class IfChangedTagTests(SimpleTestCase):
class IfChangedTests(SimpleTestCase):
+ @classmethod
+ def setUpClass(cls):
+ cls.engine = Engine()
+ super(IfChangedTests, cls).setUpClass()
+
def test_ifchanged_concurrency(self):
"""
#15849 -- ifchanged should be thread-safe.
"""
- template = Template('[0{% for x in foo %},{% with var=get_value %}{% ifchanged %}{{ var }}{% endifchanged %}{% endwith %}{% endfor %}]')
+ template = self.engine.from_string(
+ '[0{% for x in foo %},{% with var=get_value %}{% ifchanged %}'
+ '{{ var }}{% endifchanged %}{% endwith %}{% endfor %}]'
+ )
# Using generator to mimic concurrency.
# The generator is not passed to the 'for' loop, because it does a list(values)
@@ -184,6 +192,6 @@ class IfChangedTests(SimpleTestCase):
"""
#19890. The content of ifchanged template tag was rendered twice.
"""
- template = Template('{% ifchanged %}{% cycle "1st time" "2nd time" %}{% endifchanged %}')
+ template = self.engine.from_string('{% ifchanged %}{% cycle "1st time" "2nd time" %}{% endifchanged %}')
output = template.render(Context({}))
self.assertEqual(output, '1st time')