[ZPT] CVS: Zope/lib/python/TAL/tests - test_files.py:1.5.100.1 test_htmltalparser.py:1.29.6.1 test_talinterpreter.py:1.3.100.1

Florent Guillaume fg@nuxeo.com
Wed, 18 Sep 2002 10:54:14 -0400


Update of /cvs-repository/Zope/lib/python/TAL/tests
In directory cvs.zope.org:/tmp/cvs-serv21162/lib/python/TAL/tests

Modified Files:
      Tag: Zope-2_6-branch
	test_files.py test_htmltalparser.py test_talinterpreter.py 
Log Message:
Merge of the Zope-2_6-i18n-branch into Zope-2_6-i18n.

Impacted code:
- TAL: merge of the 2.7 i18n stuff, unicode fixes, tests.
- PageTemplates: addition of a global translation service and of its use
  by the TALES engine, unicode fixes, tests.
- StructuredText: unicode fixes, tests.



=== Zope/lib/python/TAL/tests/test_files.py 1.5 => 1.5.100.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	Wed Sep 18 10:54:13 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_htmltalparser.py 1.29 => 1.29.6.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	Wed Sep 18 10:54:13 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.100.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	Wed Sep 18 10:54:13 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()