summaryrefslogtreecommitdiff
path: root/tests/template_tests/syntax_tests/test_if_changed.py
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2015-06-04 12:50:07 +0100
committerTim Graham <timograham@gmail.com>2015-06-06 09:25:11 -0400
commita391b17ad24bc5f255a3928c23c158c79004c656 (patch)
tree58ad2bee78b2bf099e69c3052c1e512ff291dd30 /tests/template_tests/syntax_tests/test_if_changed.py
parent2a7c59cd885b4c9f0584015c34c17c9ebca6d417 (diff)
Fixed #23516 -- Added caching of include tag Template objects
This also speeds up for loops that render the same template multiple times.
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, 14 insertions, 0 deletions
diff --git a/tests/template_tests/syntax_tests/test_if_changed.py b/tests/template_tests/syntax_tests/test_if_changed.py
index 09cdc34a88..ee67c64218 100644
--- a/tests/template_tests/syntax_tests/test_if_changed.py
+++ b/tests/template_tests/syntax_tests/test_if_changed.py
@@ -196,3 +196,17 @@ class IfChangedTests(SimpleTestCase):
template = self.engine.from_string('{% ifchanged %}{% cycle "1st time" "2nd time" %}{% endifchanged %}')
output = template.render(Context({}))
self.assertEqual(output, '1st time')
+
+ def test_include(self):
+ """
+ #23516 -- This works as a regression test only if the cached loader
+ isn't used. Hence we don't use the @setup decorator.
+ """
+ engine = Engine(loaders=[
+ ('django.template.loaders.locmem.Loader', {
+ 'template': '{% for x in vars %}{% include "include" %}{% endfor %}',
+ 'include': '{% ifchanged %}{{ x }}{% endifchanged %}',
+ }),
+ ])
+ output = engine.render_to_string('template', dict(vars=[1, 1, 2, 2, 3, 3]))
+ self.assertEqual(output, "123")