aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_template.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-03-30 19:51:24 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-03-30 19:51:24 -0400
commitd1e8233c2efa9a231c3a5fe91469189e289e2f5c (patch)
treeec7b408ecac3068a406e4e38b3fe89ca9912d76c /test/test_template.py
parent951d15087515582e0d08bbaecdd55469cb3fc17b (diff)
downloadexternal_python_mako-d1e8233c2efa9a231c3a5fe91469189e289e2f5c.tar.gz
external_python_mako-d1e8233c2efa9a231c3a5fe91469189e289e2f5c.tar.bz2
external_python_mako-d1e8233c2efa9a231c3a5fe91469189e289e2f5c.zip
- UNDEFINED is a reserved word too, fix docs, add testsrel_0_7_0
Diffstat (limited to 'test/test_template.py')
-rw-r--r--test/test_template.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/test/test_template.py b/test/test_template.py
index 9841ac8..ae14d40 100644
--- a/test/test_template.py
+++ b/test/test_template.py
@@ -747,7 +747,38 @@ class UndefinedVarsTest(TemplateTest):
result_lines(t.render(t="T")),
['t is: T', 'a,b,c']
)
-
+
+class ReservedNameTest(TemplateTest):
+ def test_names_on_context(self):
+ for name in ('context', 'loop', 'UNDEFINED'):
+ assert_raises_message(
+ exceptions.NameConflictError,
+ r"Reserved words passed to render\(\): %s" % name,
+ Template("x").render, **{name:'foo'}
+ )
+
+ def test_names_in_template(self):
+ for name in ('context', 'loop', 'UNDEFINED'):
+ assert_raises_message(
+ exceptions.NameConflictError,
+ r"Reserved words declared in template: %s" % name,
+ Template, "<%% %s = 5 %%>" % name
+ )
+
+ def test_exclude_loop_context(self):
+ self._do_memory_test(
+ "loop is ${loop}",
+ "loop is 5",
+ template_args=dict(loop=5),
+ enable_loop=False
+ )
+
+ def test_exclude_loop_template(self):
+ self._do_memory_test(
+ "<% loop = 12 %>loop is ${loop}",
+ "loop is 12",
+ enable_loop=False
+ )
class ControlTest(TemplateTest):
def test_control(self):