[Zope-Checkins]
SVN: Zope/branches/ajung-zpt-end-game/lib/python/TAL/tests/test_talinterpreter.py
- Adjust test fixtures to work with new translation domain
API of the tal interpreter
Philipp von Weitershausen
philikon at philikon.de
Sun May 28 19:15:46 EDT 2006
Log message for revision 68322:
- Adjust test fixtures to work with new translation domain API of the tal interpreter
- Apply usual tal:omit-tag fix to make the element carrying i18n:name go away
- Disable a test that was testing madness (mixing unicode and encoded strings)
Changed:
U Zope/branches/ajung-zpt-end-game/lib/python/TAL/tests/test_talinterpreter.py
-=-
Modified: Zope/branches/ajung-zpt-end-game/lib/python/TAL/tests/test_talinterpreter.py
===================================================================
--- Zope/branches/ajung-zpt-end-game/lib/python/TAL/tests/test_talinterpreter.py 2006-05-28 23:14:22 UTC (rev 68321)
+++ Zope/branches/ajung-zpt-end-game/lib/python/TAL/tests/test_talinterpreter.py 2006-05-28 23:15:46 UTC (rev 68322)
@@ -105,14 +105,15 @@
def test_structure_replace_with_messageid_and_i18nname(self):
program, macros = self._compile(
'<div i18n:translate="" >'
- '<span tal:replace="structure foo" i18n:name="foo_name"/>'
+ '<span tal:replace="structure foo" i18n:name="foo_name"'
+ ' i18n:translate=""/>'
'</div>')
self._check(program, '<div>FOOVALUE</div>\n')
def test_complex_replace_with_messageid_and_i18nname(self):
program, macros = self._compile(
'<div i18n:translate="" >'
- '<em i18n:name="foo_name">'
+ '<em i18n:name="foo_name" tal:omit-tag="">'
'<span tal:replace="foo"/>'
'</em>'
'</div>')
@@ -146,7 +147,7 @@
'<div>THIS IS TEXT FOR <span>BARVALUE</span>.</div>\n')
def test_translate_static_text_as_dynamic_from_bytecode(self):
- program = [('version', '1.5'),
+ program = [('version', '1.6'),
('mode', 'html'),
('setPosition', (1, 0)),
('beginScope', {'i18n:translate': ''}),
@@ -178,23 +179,8 @@
self._check(program,
'<div>THIS IS TEXT FOR <span>BARVALUE</span>.</div>\n')
- def _getCollectingTranslationDomain(self):
- class CollectingTranslationService(DummyTranslationService):
- data = []
-
- def translate(self, domain, msgid, mapping=None,
- context=None, target_language=None, default=None):
- self.data.append((msgid, mapping))
- return DummyTranslationService.translate(
- self,
- domain, msgid, mapping, context, target_language, default)
-
- xlatsvc = CollectingTranslationService()
- self.engine.translationService = xlatsvc
- return xlatsvc
-
def test_for_correct_msgids(self):
- xlatdmn = self._getCollectingTranslationDomain()
+ self.engine.translationDomain.clearMsgids()
result = StringIO()
program, macros = self._compile(
'<div i18n:translate="">This is text for '
@@ -203,7 +189,7 @@
self.interpreter = TALInterpreter(program, {}, self.engine,
stream=result)
self.interpreter()
- msgids = list(xlatdmn.data)
+ msgids = self.engine.translationDomain.getMsgids('default')
msgids.sort()
self.assertEqual(2, len(msgids))
self.assertEqual('BaRvAlUe', msgids[0][0])
@@ -217,7 +203,7 @@
# Test for Issue 314: i18n:translate removes line breaks from
# <pre>...</pre> contents
# HTML mode
- xlatdmn = self._getCollectingTranslationDomain()
+ self.engine.translationDomain.clearMsgids()
result = StringIO()
program, macros = self._compile(
'<div i18n:translate=""> This is text\n'
@@ -227,7 +213,7 @@
self.interpreter = TALInterpreter(program, {}, self.engine,
stream=result)
self.interpreter()
- msgids = list(xlatdmn.data)
+ msgids = self.engine.translationDomain.getMsgids('default')
msgids.sort()
self.assertEqual(2, len(msgids))
self.assertEqual(' This is text\n <b>\tfor</b>\n pre. ', msgids[0][0])
@@ -238,7 +224,7 @@
result.getvalue())
# XML mode
- xlatdmn = self._getCollectingTranslationDomain()
+ self.engine.translationDomain.clearMsgids()
result = StringIO()
parser = TALParser()
parser.parseString(
@@ -250,7 +236,7 @@
self.interpreter = TALInterpreter(program, {}, self.engine,
stream=result)
self.interpreter()
- msgids = list(xlatdmn.data)
+ msgids = self.engine.translationDomain.getMsgids('default')
msgids.sort()
self.assertEqual(1, len(msgids))
self.assertEqual('This is text <b> for</b> barvalue.', msgids[0][0])
@@ -260,7 +246,7 @@
result.getvalue())
def test_raw_msgids_and_i18ntranslate_i18nname(self):
- xlatdmn = self._getCollectingTranslationDomain()
+ self.engine.translationDomain.clearMsgids()
result = StringIO()
program, macros = self._compile(
'<div i18n:translate=""> This is text\n \tfor\n'
@@ -269,7 +255,7 @@
self.interpreter = TALInterpreter(program, {}, self.engine,
stream=result)
self.interpreter()
- msgids = list(xlatdmn.data)
+ msgids = self.engine.translationDomain.getMsgids('default')
msgids.sort()
self.assertEqual(2, len(msgids))
self.assertEqual(' \tRaW\n ', msgids[0][0])
@@ -416,12 +402,13 @@
expected = u"foo baz"
self.assertEqual(interpolate(text, mapping), expected)
- def test_unicode_mixed_unknown_encoding(self):
- # This test assumes that sys.getdefaultencoding is ascii...
- text = u"foo ${bar}"
- mapping = {u'bar': 'd\xe9j\xe0'}
- expected = u"foo d\\xe9j\\xe0"
- self.assertEqual(interpolate(text, mapping), expected)
+ # this test just tests sick behaviour, we'll disable it
+ #def test_unicode_mixed_unknown_encoding(self):
+ # # This test assumes that sys.getdefaultencoding is ascii...
+ # text = u"foo ${bar}"
+ # mapping = {u'bar': 'd\xe9j\xe0'}
+ # expected = u"foo d\\xe9j\\xe0"
+ # self.assertEqual(interpolate(text, mapping), expected)
def test_suite():
suite = unittest.makeSuite(I18NErrorsTestCase)
More information about the Zope-Checkins
mailing list