[Zope-Checkins] CVS: Zope3/lib/python/Zope/TAL/tests - test_htmltalparser.py:1.32.6.1
Barry Warsaw
barry@wooz.org
Tue, 25 Jun 2002 20:07:29 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/TAL/tests
In directory cvs.zope.org:/tmp/cvs-serv9739/tests
Modified Files:
Tag: tal-i18n-refactor-branch
test_htmltalparser.py
Log Message:
First pass at refactoring the i18n tal attribute handling. Some stuff
works better, some stuff is broken (which is why this is on a
branch). In particular i18n:name + tal:content now works, as does
i18n:name + implicit tal:replace, but i18n:name + (explicit)
tal:replace is broken. Checkpointing so I can work on this at home.
Specific changes:
check_i18n_name_around_tal_content(),
check_i18n_name_around_tal_content(): New structure tests.
=== Zope3/lib/python/Zope/TAL/tests/test_htmltalparser.py 1.32 => 1.32.6.1 ===
def check_i18n_name(self):
+ # input/test21.html
self._run_check('''\
<span i18n:translate="">
<span tal:replace="str:Lomax" i18n:name="name" /> was born in
@@ -683,6 +684,7 @@
])
def check_i18n_data(self):
+ # input/test23.html
self._run_check('''\
<span i18n:data="here/currentTime"
i18n:translate="timefmt">2:32 pm</span>
@@ -736,6 +738,7 @@
])
def check_i18n_explicit_msgid_with_name(self):
+ # input/test26.html
self._run_check('''\
<span i18n:translate="jobnum">
Job #<span tal:replace="context/@@object_name"
@@ -763,6 +766,89 @@
('endScope', ())])),
('endScope', ()),
('rawtextColumn', ('</span>\n', 0))
+ ])
+
+ def check_i18n_name_around_tal_content(self):
+ # input/test28.html
+ self._run_check('''\
+<p i18n:translate="verify">Your contact email address is recorded as
+ <span i18n:name="email">
+ <a href="mailto:user@example.com"
+ tal:content="request/submitter">user@host.com</a></span>
+</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,
+ {'i18n:name': 'email'})),
+ ('i18nVariable',
+ ('email',
+ [('rawtextBeginScope',
+ ('\n ',
+ 4,
+ (3, 4),
+ 0,
+ {'href': 'mailto:user@example.com',
+ 'tal:content': 'request/submitter'})),
+ ('startTag',
+ ('a',
+ [('href', 'href="mailto:user@example.com"'),
+ ('tal:content', 'request/submitter', 'tal')])),
+ ('insertText',
+ ('$request/submitter$',
+ [('rawtextOffset', ('user@host.com', 13))])),
+ ('endScope', ()),
+ ('rawtextOffset', ('</a>', 4))])),
+ ('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))])),
+ ('endScope', ()),
+ ('rawtextColumn', ('\n', 0))])),
+ ('endScope', ()),
+ ('rawtextColumn', ('</p>\n', 0))
])