[ZPT] CVS: Zope/lib/python/TAL/tests - test_files.py:1.5.98.1 test_htmlparser.py:1.18.80.1 test_htmltalparser.py:1.29.4.1 test_talinterpreter.py:1.3.98.1
Chris McDonough
chrism@zope.com
Sat, 28 Sep 2002 21:41:07 -0400
Update of /cvs-repository/Zope/lib/python/TAL/tests
In directory cvs.zope.org:/tmp/cvs-serv16902/lib/python/TAL/tests
Modified Files:
Tag: chrism-install-branch
test_files.py test_htmlparser.py test_htmltalparser.py
test_talinterpreter.py
Log Message:
Merge chrism-install-branch with head. Apologies for the spew.
=== Zope/lib/python/TAL/tests/test_files.py 1.5 => 1.5.98.1 ===
--- Zope/lib/python/TAL/tests/test_files.py:1.5 Thu Oct 18 12:22:09 2001
+++ Zope/lib/python/TAL/tests/test_files.py Sat Sep 28 21:40:36 2002
@@ -17,6 +17,10 @@
self.__dir = dir
unittest.TestCase.__init__(self)
+ def shortDescription(self):
+ return os.path.join("...", "TAL", "tests", "input",
+ os.path.basename(self.__file))
+
def runTest(self):
basename = os.path.basename(self.__file)
#sys.stdout.write(basename + " ")
=== Zope/lib/python/TAL/tests/test_htmlparser.py 1.18 => 1.18.80.1 ===
--- Zope/lib/python/TAL/tests/test_htmlparser.py:1.18 Mon Dec 3 11:43:41 2001
+++ Zope/lib/python/TAL/tests/test_htmlparser.py Sat Sep 28 21:40:36 2002
@@ -294,6 +294,12 @@
("endtag", "script"),
])
+ def check_enumerated_attr_type(self):
+ s = "<!DOCTYPE doc [<!ATTLIST doc attr (a | b) >]>"
+ self._run_check(s, [
+ ('decl', 'DOCTYPE doc [<!ATTLIST doc attr (a | b) >]'),
+ ])
+
# Support for the Zope regression test framework:
def test_suite():
=== Zope/lib/python/TAL/tests/test_htmltalparser.py 1.29 => 1.29.4.1 === (588/688 lines abridged)
--- Zope/lib/python/TAL/tests/test_htmltalparser.py:1.29 Wed Aug 14 17:58:54 2002
+++ Zope/lib/python/TAL/tests/test_htmltalparser.py Sat Sep 28 21:40:36 2002
@@ -1,4 +1,17 @@
-#! /usr/bin/env python1.5
+#! /usr/bin/env python
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
"""Tests for the HTMLTALParser code generator."""
import pprint
@@ -7,7 +20,6 @@
from TAL.tests import utils
import unittest
-from string import rfind
from TAL import HTMLTALParser
from TAL.TALDefs import TAL_VERSION, TALError, METALError
@@ -24,7 +36,7 @@
if p1 and p2:
op1, args1 = p1[-1]
op2, args2 = p2[0]
- if op1[:7] == 'rawtext' and op2[:7] == 'rawtext':
+ if op1.startswith('rawtext') and op2.startswith('rawtext'):
return (p1[:-1]
+ [rawtext(args1[0] + args2[0])]
+ p2[1:])
@@ -60,7 +72,7 @@
def rawtext(s):
"""Compile raw text to the appropriate instruction."""
if "\n" in s:
- return ("rawtextColumn", (s, len(s) - (rfind(s, "\n") + 1)))
+ return ("rawtextColumn", (s, len(s) - (s.rfind("\n") + 1)))
else:
return ("rawtextOffset", (s, len(s)))
@@ -100,25 +112,6 @@
self._run_check("<a><b></a></b>", [])
self.assertRaises(HTMLTALParser.NestingError, check)
[-=- -=- -=- 588 lines omitted -=- -=- -=-]
+ ('rawtextOffset', ('</a>', 4))],
+ None)),
+ ('endScope', ()),
+ ('rawtextColumn', ('\n', 0))])),
+ ('endScope', ()),
+ ('rawtextColumn', ('</p>\n', 0))
+ ])
+
+ def check_i18n_name_with_tal_content(self):
+ # input/test27.html
+ self._run_check('''\
+<p i18n:translate="verify">Your contact email address is recorded as
+ <a href="mailto:user@example.com"
+ tal:content="request/submitter"
+ i18n:name="email">user@host.com</a>
+</p>
+''', [
+ ('setPosition', (1, 0)),
+ ('beginScope', {'i18n:translate': 'verify'}),
+ ('startTag', ('p', [('i18n:translate', 'verify', 'i18n')])),
+ ('insertTranslation',
+ ('verify',
+ [('rawtextBeginScope',
+ ('Your contact email address is recorded as\n ',
+ 4,
+ (2, 4),
+ 0,
+ {'href': 'mailto:user@example.com',
+ 'i18n:name': 'email',
+ 'tal:content': 'request/submitter'})),
+ ('i18nVariable',
+ ('email',
+ [('startTag',
+ ('a',
+ [('href', 'href="mailto:user@example.com"'),
+ ('tal:content', 'request/submitter', 'tal'),
+ ('i18n:name', 'email', 'i18n')])),
+ ('insertText',
+ ('$request/submitter$',
+ [('rawtextOffset', ('user@host.com', 13))])),
+ ('rawtextOffset', ('</a>', 4))],
+ None)),
+ ('endScope', ()),
+ ('rawtextColumn', ('\n', 0))])),
+ ('endScope', ()),
+ ('rawtextColumn', ('</p>\n', 0))
+ ])
def test_suite():
=== Zope/lib/python/TAL/tests/test_talinterpreter.py 1.3 => 1.3.98.1 ===
--- Zope/lib/python/TAL/tests/test_talinterpreter.py:1.3 Wed Oct 17 16:28:01 2001
+++ Zope/lib/python/TAL/tests/test_talinterpreter.py Sat Sep 28 21:40:36 2002
@@ -68,6 +68,24 @@
interp()
self.assertEqual(sio.getvalue(), 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)
+
+ 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)
+
def test_suite():
suite = unittest.TestSuite()