summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjonathan vanasco <jonathan@2xlp.com>2015-03-25 16:38:38 -0400
committerjonathan vanasco <jonathan@2xlp.com>2015-03-25 16:38:38 -0400
commit78861634da9ffa449be11654912ac16c371753d0 (patch)
treea0763f55e729cebb6b10a924fb3001fd86b4b99a
parent33879f782bf59438f4e9c224139c59f28c5b671a (diff)
downloadmako-78861634da9ffa449be11654912ac16c371753d0.tar.gz
added tests
-rw-r--r--test/test_def.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/test_def.py b/test/test_def.py
index 8b32561..19142c8 100644
--- a/test/test_def.py
+++ b/test/test_def.py
@@ -123,6 +123,41 @@ class DefTest(TemplateTest):
filters=flatten_result,
template_args={'q': 5, 'zq': 'test'})
+ def test_def_operations(self):
+ """test get/list/has def"""
+
+ template = Template("""
+
+ this is the body
+
+ <%def name="a()">
+ this is a
+ </%def>
+
+ <%def name="b(x, y)">
+ this is b, ${x} ${y}
+ </%def>
+
+ """)
+
+ assert template.get_def("a")
+ assert template.get_def("b")
+ assert_raises(AttributeError,
+ template.get_def,
+ ("c")
+ )
+
+ assert template.has_def("a")
+ assert template.has_def("b")
+ assert not template.has_def("c")
+
+ defs = template.list_defs()
+ assert "a" in defs
+ assert "b" in defs
+ assert "body" in defs
+ assert "c" not in defs
+
+
class ScopeTest(TemplateTest):
"""test scoping rules. The key is, enclosing
scope always takes precedence over contextual scope."""