[ZPT] CVS: Packages/TAL - test_talinterpreter.py:1.1.6.1

evan@cvs.baymountain.com evan@cvs.baymountain.com
Wed, 18 Jul 2001 12:09:06 -0400


Update of /cvs-repository/Packages/TAL/tests
In directory cvs.baymountain.com:/tmp/cvs-serv32434/tests

Modified Files:
      Tag: tal-1_3_0
	test_talinterpreter.py 
Log Message:
Version 1.3.3



--- Updated File test_talinterpreter.py in package Packages/TAL --
--- test_talinterpreter.py	10 Apr 2001 02:48:49 -0000	1.1
+++ test_talinterpreter.py	18 Jul 2001 16:08:36 -0000	1.1.6.1
@@ -6,13 +6,15 @@
 import utils
 import unittest
 
+from StringIO import StringIO
+
 from TAL.TALDefs import METALError
 from TAL.HTMLTALParser import HTMLTALParser
 from TAL.TALInterpreter import TALInterpreter
 from TAL.DummyEngine import DummyEngine
 
 
-class MacroErrorsTestCase(unittest.TestCase):
+class TestCaseBase(unittest.TestCase):
 
     def _compile(self, source):
         parser = HTMLTALParser()
@@ -20,6 +22,9 @@
         program, macros = parser.getCode()
         return program, macros
 
+
+class MacroErrorsTestCase(TestCaseBase):
+
     def setUp(self):
         dummy, macros = self._compile('<p metal:define-macro="M">Booh</p>')
         self.macro = macros['M']
@@ -42,9 +47,32 @@
         self.macro[0] = ("version", "duh")
 
 
+class OutputPresentationTestCase(TestCaseBase):
+
+    def check_attribute_wrapping(self):
+        # To make sure the attribute-wrapping code is invoked, we have to
+        # include at least one TAL/METAL attribute to avoid having the start
+        # tag optimized into a rawtext instruction.
+        INPUT = r"""
+        <html this='element' has='a' lot='of' attributes=', so' the='output'
+              needs='to' be='line' wrapped='.' tal:define='foo nothing'>
+        </html>"""
+        EXPECTED = r'''
+        <html this="element" has="a" lot="of"
+              attributes=", so" the="output" needs="to"
+              be="line" wrapped=".">
+        </html>''' "\n"
+        program, macros = self._compile(INPUT)
+        sio = StringIO()
+        interp = TALInterpreter(program, {}, DummyEngine(), sio, wrap=60)
+        interp()
+        self.assertEqual(sio.getvalue(), EXPECTED)
+
+
 def test_suite():
     suite = unittest.TestSuite()
     suite.addTest(unittest.makeSuite(MacroErrorsTestCase, "check_"))
+    suite.addTest(unittest.makeSuite(OutputPresentationTestCase, "check_"))
     return suite