aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_cache.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_cache.py')
-rw-r--r--test/test_cache.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/test_cache.py b/test/test_cache.py
index d898b02..1c7b42a 100644
--- a/test/test_cache.py
+++ b/test/test_cache.py
@@ -139,6 +139,37 @@ class CacheTest(TemplateTest):
]
assert m.kwargs == {}
+ def test_dynamic_key_with_context(self):
+ t = Template("""
+ <%block name="foo" cached="True" cache_key="${mykey}">
+ some block
+ </%block>
+ """)
+ m = self._install_mock_cache(t)
+ t.render(mykey="thekey")
+ t.render(mykey="thekey")
+ eq_(
+ result_lines(t.render(mykey="thekey")),
+ ["some block"]
+ )
+ eq_(m.key, "thekey")
+
+ t = Template("""
+ <%def name="foo()" cached="True" cache_key="${mykey}">
+ some def
+ </%def>
+ ${foo()}
+ """)
+ m = self._install_mock_cache(t)
+ t.render(mykey="thekey")
+ t.render(mykey="thekey")
+ eq_(
+ result_lines(t.render(mykey="thekey")),
+ ["some def"]
+ )
+ eq_(m.key, "thekey")
+
+
def test_dynamic_key_with_funcargs(self):
t = Template("""
<%def name="foo(num=5)" cached="True" cache_key="foo_${str(num)}">