Permalink
Browse files

Add a test to verify the use of getVar and write inside of a PSP

  • Loading branch information...
1 parent 0f4310a commit ab598b6db1ce0c63cfe62b35d323f75064df9a19 @rtyler rtyler committed Dec 19, 2009
Showing with 17 additions and 1 deletion.
  1. +17 −1 cheetah/Tests/SyntaxAndOutput.py
View
18 cheetah/Tests/SyntaxAndOutput.py
@@ -162,7 +162,8 @@ def verify(self, input, expectedOutput,
**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 @@ def test6(self):
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 @@ def test9(self):
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):

0 comments on commit ab598b6

Please sign in to comment.