[Zope-Checkins] CVS: Zope/lib/python/TAL/tests - test_files.py:1.5.102.1 test_htmltalparser.py:1.29.8.1

Florent Guillaume fg@nuxeo.com
Sun, 15 Sep 2002 18:43:35 -0400


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

Modified Files:
      Tag: Zope-2_6-i18n-branch
	test_files.py test_htmltalparser.py 
Log Message:
Zope-2_6-i18n-branch is a branch off Zope-2_6-branch to integrate TAL
i18n from Zope27. This branch is based at tag Zope-2_6-i18n-base.

This first checkin is simply a direct copy of TAL and PageTemplates
tagged at baseline-for-Zope-2_6-i18n-branch in the Zope27 module, and
adapted to not get ImportErrors on interfaces. All tests pass (except
the usual failure due to expat bugs).



=== Zope/lib/python/TAL/tests/test_files.py 1.5 => 1.5.102.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	Sun Sep 15 18:43:34 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.8.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	Sun Sep 15 18:43:34 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():