[Zope-Checkins] CVS: Zope/lib/python/TAL/tests - test_talinterpreter.py:1.3.100.4
Florent Guillaume
fg@nuxeo.com
Thu, 30 Jan 2003 15:14:36 -0500
Update of /cvs-repository/Zope/lib/python/TAL/tests
In directory cvs.zope.org:/tmp/cvs-serv23953/lib/python/TAL/tests
Modified Files:
Tag: Zope-2_6-branch
test_talinterpreter.py
Log Message:
Merge an old bugfix from HEAD that hadn't been merged yet:
Collector #721: preserve syntactically valid character entities in
attributes.
=== Zope/lib/python/TAL/tests/test_talinterpreter.py 1.3.100.3 => 1.3.100.4 ===
--- Zope/lib/python/TAL/tests/test_talinterpreter.py:1.3.100.3 Thu Jan 30 13:57:12 2003
+++ Zope/lib/python/TAL/tests/test_talinterpreter.py Thu Jan 30 15:14:33 2003
@@ -63,29 +63,17 @@
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)
+ self.compare(INPUT, EXPECTED)
def check_unicode_content(self):
INPUT = """<p tal:content="python:u'déjà-vu'">para</p>"""
EXPECTED = u"""<p>déjà-vu</p>""" "\n"
- program, macros = self._compile(INPUT)
- sio = StringIO()
- interp = TALInterpreter(program, {}, DummyEngine(), sio, wrap=60)
- interp()
- self.assertEqual(sio.getvalue(), EXPECTED)
+ self.compare(INPUT, EXPECTED)
def check_unicode_structure(self):
INPUT = """<p tal:replace="structure python:u'déjà-vu'">para</p>"""
EXPECTED = u"""déjà-vu""" "\n"
- program, macros = self._compile(INPUT)
- sio = StringIO()
- interp = TALInterpreter(program, {}, DummyEngine(), sio, wrap=60)
- interp()
- self.assertEqual(sio.getvalue(), EXPECTED)
+ self.compare(INPUT, EXPECTED)
def check_i18n_replace_number(self):
INPUT = """
@@ -94,15 +82,21 @@
</p>"""
EXPECTED = u"""
<p>FOO 123</p>""" "\n"
- program, macros = self._compile(INPUT)
- sio = StringIO()
- interp = TALInterpreter(program, {}, DummyEngine(), sio, wrap=60)
- interp()
- self.assertEqual(sio.getvalue(), EXPECTED)
+ self.compare(INPUT, EXPECTED)
+
+ def check_entities(self):
+ INPUT = ('<img tal:define="foo nothing" '
+ 'alt="&a;  
 &a - &; �a; <>" />')
+ EXPECTED = ('<img alt="&a;  
 '
+ '&a &#45 &; &#0a; <>" />\n')
+ self.compare(INPUT, EXPECTED)
def check_escaping(self):
INPUT = """<p tal:content="python:chr(34)+'<>&'" />"""
EXPECTED = "<p>"<>&</p>\n"
+ self.compare(INPUT, EXPECTED)
+
+ def compare(self, INPUT, EXPECTED):
program, macros = self._compile(INPUT)
sio = StringIO()
interp = TALInterpreter(program, {}, DummyEngine(), sio, wrap=60)