[Zope3-checkins] CVS: Zope3/src/zope/tal/tests -
test_talinterpreter.py:1.3.4.11
Stephan Richter
srichter at cosmos.phy.tufts.edu
Fri Aug 8 16:23:07 EDT 2003
Update of /cvs-repository/Zope3/src/zope/tal/tests
In directory cvs.zope.org:/tmp/cvs-serv18196/src/zope/tal/tests
Modified Files:
Tag: srichter-i18n-macro-interaction-branch
test_talinterpreter.py
Log Message:
Added another test to test yet another angle.
=== Zope3/src/zope/tal/tests/test_talinterpreter.py 1.3.4.10 => 1.3.4.11 ===
--- Zope3/src/zope/tal/tests/test_talinterpreter.py:1.3.4.10 Fri Aug 8 15:09:54 2003
+++ Zope3/src/zope/tal/tests/test_talinterpreter.py Fri Aug 8 15:23:03 2003
@@ -22,7 +22,7 @@
from zope.tal.taldefs import METALError, I18NError
from zope.tal.htmltalparser import HTMLTALParser
from zope.tal.talinterpreter import TALInterpreter
-from zope.tal.dummyengine import DummyEngine
+from zope.tal.dummyengine import DummyEngine, DummyTranslationService
from zope.tal.tests import utils
from zope.i18n.messageid import MessageID
@@ -133,10 +133,43 @@
# The follwoing code is also dumb; tell the user just that!
program, macros = self._compile(
'<div i18n:translate="">This is text for '
- '<span i18n:translate="" tal:content="bar" i18n:name="foo_name"/>'
- '.</div>')
+ '<span i18n:translate="" tal:content="bar" '
+ 'i18n:name="bar_name"/>.</div>')
self._check(program,
'<div>THIS IS TEXT FOR <span>BARVALUE</span></div>\n')
+
+
+ def test_for_correct_msgids(self):
+
+ class CollectingTranslationService(DummyTranslationService):
+
+ def __init__(self):
+ self.data = []
+
+ def translate(self, msgid, domain=None, mapping=None,
+ context=None, target_language=None, default=None):
+ self.data.append(msgid)
+ return super(CollectingTranslationService, self).translate(
+ msgid, domain, mapping, context, target_language, default)
+
+
+ engine = DummyEngine()
+ engine.setLocal('bar', 'BaRvAlUe')
+ engine.translationService = CollectingTranslationService()
+ result = StringIO()
+ program, macros = self._compile(
+ '<div i18n:translate="">This is text for '
+ '<span i18n:translate="" tal:content="bar" '
+ 'i18n:name="bar_name"/>.</div>')
+ self.interpreter = TALInterpreter(program, {}, engine,
+ stream=result)
+ self.interpreter()
+ self.assert_('BaTvAlUe' in engine.translationService.data)
+ self.assert_('<div>This is text for ${bar_name}.</div>' in
+ engine.translationService.data)
+ self.assertEqual(
+ '<div>THIS IS TEXT FOR <span>BARVALUE</span></div>\n',
+ result.getvalue())
class I18NErrorsTestCase(TestCaseBase):
More information about the Zope3-Checkins
mailing list