summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorR. Tyler Ballance <tyler@monkeypox.org>2009-12-19 14:29:05 -0800
committerR. Tyler Ballance <tyler@monkeypox.org>2009-12-19 14:29:05 -0800
commitab598b6db1ce0c63cfe62b35d323f75064df9a19 (patch)
tree194c055bd07bdfc0f6d859aaf8081bb10a96d236
parent0f4310ae128a0566d863d47a677b6a0b35d8dc18 (diff)
downloadpython-cheetah-ab598b6db1ce0c63cfe62b35d323f75064df9a19.tar.gz
Add a test to verify the use of getVar and write inside of a PSP
-rw-r--r--cheetah/Tests/SyntaxAndOutput.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/cheetah/Tests/SyntaxAndOutput.py b/cheetah/Tests/SyntaxAndOutput.py
index 66e8bd7..92c129b 100644
--- a/cheetah/Tests/SyntaxAndOutput.py
+++ b/cheetah/Tests/SyntaxAndOutput.py
@@ -162,7 +162,8 @@ Template output mismatch:
**extraKwArgs
)
moduleCode = templateClass._CHEETAH_generatedModuleCode
- self.template = templateObj = templateClass(searchList=self.searchList())
+ searchList = self.searchList() or self._searchList
+ self.template = templateObj = templateClass(searchList=searchList)
else:
self.template = templateObj = Template(
input,
@@ -2344,6 +2345,8 @@ class UnlessDirective(OutputTest):
self.verify("#unless 0: 1234\n"*2, "1234\n"*2)
class PSP(OutputTest):
+ def searchList(self):
+ return None
def test1(self):
"""simple <%= [int] %>"""
@@ -2382,6 +2385,19 @@ class PSP(OutputTest):
self.verify("""<% for i in range(5):
i=i*2$%><%=i%>-<%end%>""", "0-2-4-6-8-")
+ def test10(self):
+ """ Using getVar and write within a PSP """
+ self._searchList = [{'me' : 1}]
+ template = '''This is my template
+<%
+me = self.getVar('me')
+if isinstance(me, int):
+ write('Bork')
+else:
+ write('Nork')
+%>'''
+ self.verify(template, 'This is my template\nBork')
+
class WhileDirective(OutputTest):
def test1(self):