[ZPT] CVS: Zope/lib/python/TAL/tests - test_files.py:1.5.94.1 test_htmltalparser.py:1.28.12.1

Fred L. Drake, Jr. fdrake@acm.org
Tue, 30 Jul 2002 16:12:54 -0400


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

Modified Files:
      Tag: Zope-2_7-development-branch
	test_files.py test_htmltalparser.py 
Log Message:
Back-port of the TAL internationalization support to Zope 2.7.

=== Zope/lib/python/TAL/tests/test_files.py 1.5 => 1.5.94.1 ===
         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.28 => 1.28.12.1 === (589/689 lines abridged)
-#! /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)
 
-    def check_cdata_mode(self):
-        """This routine should NOT detect an error with an end tag </a></b> not

[-=- -=- -=- 589 lines omitted -=- -=- -=-]

+       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():
     suite = unittest.TestSuite()