aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_call.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-08-11 15:26:58 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-08-11 15:26:58 -0400
commit49db3f99c9f09caec8d63534b371808fbd4c2209 (patch)
tree18259aedd2fb72b21163438ccfb1197d2804afe5 /test/test_call.py
parentae592c70c770e0121b3cd69947f97cfb5e736311 (diff)
downloadexternal_python_mako-49db3f99c9f09caec8d63534b371808fbd4c2209.tar.gz
external_python_mako-49db3f99c9f09caec8d63534b371808fbd4c2209.tar.bz2
external_python_mako-49db3f99c9f09caec8d63534b371808fbd4c2209.zip
- ${} expressions embedded in tags,
such as <%foo:bar x="${...}">, now allow multiline Python expressions.
Diffstat (limited to 'test/test_call.py')
-rw-r--r--test/test_call.py34
1 files changed, 31 insertions, 3 deletions
diff --git a/test/test_call.py b/test/test_call.py
index 3e6cd26..d47ec11 100644
--- a/test/test_call.py
+++ b/test/test_call.py
@@ -1,9 +1,9 @@
from mako.template import Template
from mako import util
-import unittest
from util import result_lines, flatten_result
+from test import TemplateTest, eq_
-class CallTest(unittest.TestCase):
+class CallTest(TemplateTest):
def test_call(self):
t = Template("""
<%def name="foo()">
@@ -44,6 +44,34 @@ class CallTest(unittest.TestCase):
""")
assert result_lines(t.render()) == ['foo calling comp1:', 'this is comp1, 5', 'foo calling body:', 'this is the body,', 'this is comp1, 6', 'this is bar']
+ def test_new_syntax(self):
+ """test foo:bar syntax, including multiline args and expression eval."""
+
+ t = Template("""
+ <%def name="foo(x, y, q, z)">
+ ${x}
+ ${y}
+ ${q}
+ ${",".join("%s->%s" % (a, b) for a, b in z)}
+ </%def>
+
+ <%self:foo x="this is x" y="${'some ' + 'y'}" q="
+ this
+ is
+ q"
+
+ z="${[
+ (1, 2),
+ (3, 4),
+ (5, 6)
+ ]}"/>
+ """)
+
+ eq_(
+ result_lines(t.render()),
+ ['this is x', 'some y', 'this', 'is', 'q', '1->2,3->4,5->6']
+ )
+
def test_ccall_caller(self):
t = Template("""
<%def name="outer_func()">
@@ -380,7 +408,7 @@ class CallTest(unittest.TestCase):
""")
assert result_lines(t.render()) == ['this is a', 'this is b', 'this is c:', "this is the body in b's call", 'the embedded "d" is:', 'this is d']
-class SelfCacheTest(unittest.TestCase):
+class SelfCacheTest(TemplateTest):
"""this test uses a now non-public API."""
def test_basic(self):