[Zope3-checkins] CVS: Zope3/src/zope/tal/tests - test_talinterpreter.py:1.3.6.2

Stephan Richter srichter at cosmos.phy.tufts.edu
Wed Aug 20 12:24:18 EDT 2003


Update of /cvs-repository/Zope3/src/zope/tal/tests
In directory cvs.zope.org:/tmp/cvs-serv3164/tests

Modified Files:
      Tag: srichter-inlinepython-branch
	test_talinterpreter.py 
Log Message:
Got some more tests working.


=== Zope3/src/zope/tal/tests/test_talinterpreter.py 1.3.6.1 => 1.3.6.2 ===
--- Zope3/src/zope/tal/tests/test_talinterpreter.py:1.3.6.1	Wed Aug 20 09:00:01 2003
+++ Zope3/src/zope/tal/tests/test_talinterpreter.py	Wed Aug 20 11:24:17 2003
@@ -71,10 +71,98 @@
         self.interpreter()
         self.assertEqual(expected, result.getvalue())
 
-    def test_simple_script(self):
+    def test_simple(self):
         program, macros = self._compile(
             '<p tal:script="server-python">print "hello"</p>')
         self._check(program, '<p>hello\n</p>\n')
+
+    def test_indent(self):
+        program, macros = self._compile(
+            '<p tal:script="server-python">\n'
+            '  print "hello"\n'
+            '</p>')
+        self._check(program, '<p>hello\n</p>\n')
+
+    def test_multiline(self):
+        program, macros = self._compile(
+            '<p tal:script="server-python">\n'
+            '  print "hello"\n'
+            '  print "world"\n'
+            '</p>')
+        self._check(program, '<p>hello\nworld\n</p>\n')
+
+    def test_variable_assignment(self):
+        program, macros = self._compile(
+            '<p tal:script="server-python">\n'
+            '  x = 1\n'
+            '  print x'
+            '</p>')
+        self._check(program, '<p>1\n</p>\n')
+
+    def test_local_variable_assignment(self):
+        program, macros = self._compile(
+            '<p tal:script="server-python">\n'
+            '  x = 1\n'
+            '</p>')
+        self._check(program, '<p></p>\n')
+        self.assertEqual(self.engine.codeLocals['x'], 1)
+
+    def test_global_variable_assignment(self):
+        program, macros = self._compile(
+            '<p tal:script="server-python">\n'
+            '  global x\n'
+            '  x = 1\n'
+            '</p>')
+        self._check(program, '<p></p>\n')
+        self.assertEqual(self.engine.codeGlobals['x'], 1)
+
+    def test_use_global_variables_outside(self):
+        program, macros = self._compile(
+            '<p tal:script="server-python">\n'
+            '  global x\n'
+            '  x = 1\n'
+            '</p>\n'
+            '<span tal:replace="x" />')
+        self._check(program, '<p></p>\n1\n')
+        self.assertEqual(self.engine.codeGlobals['x'], 1)
+
+    def test_script_and_tal_block(self):
+        program, macros = self._compile(
+            '<tal:block script="server-python">\n'
+            '  global x\n'
+            '  x = 1\n'
+            '</tal:block>\n'
+            '<span tal:replace="x" />')
+        self._check(program, '\n1\n')
+        self.assertEqual(self.engine.codeGlobals['x'], 1)
+
+    def test_script_and_tal_block_having_inside_print(self):
+        program, macros = self._compile(
+            '<tal:block script="server-python">\n'
+            '  print "hello"'
+            '</tal:block>')
+        self._check(program, 'hello\n\n')
+
+    def test_script_and_omittag(self):
+        program, macros = self._compile(
+            '<p tal:omit-tag="" tal:script="server-python">\n'
+            '  print "hello"'
+            '</p>')
+        self._check(program, 'hello\n\n')
+
+    def test_script_and_inside_tags(self):
+        program, macros = self._compile(
+            '<p tal:omit-tag="" tal:script="server-python">\n'
+            '  print "<b>hello</b>"'
+            '</p>')
+        self._check(program, '<b>hello</b>\n\n')
+
+    def test_script_and_inside_tags_with_tal(self):
+        program, macros = self._compile(
+            '<p tal:omit-tag="" tal:script="server-python"> <!--\n'
+            '  print """<b tal:replace="string:foo">hello</b>"""\n'
+            '--></p>')
+        self._check(program, '<b tal:replace="string:foo">hello</b>\n\n')
 
 
 class I18NCornerTestCase(TestCaseBase):




More information about the Zope3-Checkins mailing list