[Zope3-checkins] CVS: Zope3/src/zope/tal/tests - test_talinterpreter.py:1.3.4.5

Stephan Richter srichter at cosmos.phy.tufts.edu
Fri Aug 8 14:15:40 EDT 2003


Update of /cvs-repository/Zope3/src/zope/tal/tests
In directory cvs.zope.org:/tmp/cvs-serv28943/src/zope/tal/tests

Modified Files:
      Tag: srichter-i18n-macro-interaction-branch
	test_talinterpreter.py 
Log Message:
Compressed test code to be a bit more sane.


=== Zope3/src/zope/tal/tests/test_talinterpreter.py 1.3.4.4 => 1.3.4.5 ===
--- Zope3/src/zope/tal/tests/test_talinterpreter.py:1.3.4.4	Fri Aug  8 12:56:11 2003
+++ Zope3/src/zope/tal/tests/test_talinterpreter.py	Fri Aug  8 13:15:34 2003
@@ -61,71 +61,44 @@
 
 class I18NCornerTestCase(TestCaseBase):
 
-    def _check(self, program, result):
-        pass
-
-    def test_simple_messageid_translate(self):
-        # This test is mainly here to make sure our DummyEngine works
-        # correctly.
+    def _check(self, program, expected):
         self.engine = DummyEngine()
         self.engine.setLocal('foo', MessageID('FoOvAlUe', 'default'))
-
-        program, macros = self._compile('<span tal:content="foo"/>')
         result = StringIO()
         self.interpreter = TALInterpreter(program, {}, self.engine,
                                           stream=result)
         self.interpreter()
-        self.assertEqual('<span>FOOVALUE</span>\n', result.getvalue())
+        self.assertEqual(expected, result.getvalue())
 
-        program, macros = self._compile('<span tal:replace="foo"/>')
-        result = StringIO()
-        self.interpreter = TALInterpreter(program, {}, self.engine,
-                                          stream=result)
-        self.interpreter()
-        self.assertEqual('FOOVALUE\n', result.getvalue())
+    def test_simple_messageid_translate(self):
+        # This test is mainly here to make sure our DummyEngine works
+        # correctly.
+        program, macros = self._compile('<span tal:content="foo"/>')
+        self._check(program, '<span>FOOVALUE</span>\n')
 
+        program, macros = self._compile('<span tal:replace="foo"/>')
+        self._check(program, 'FOOVALUE\n')
 
     def test_replace_with_messageid_and_i18nname(self):
         program, macros = self._compile(
-            '<d i18n:translate="" >'
+            '<div i18n:translate="" >'
             '<span tal:replace="foo" i18n:name="foo_name"/>'
-            '</d>')
-        self.engine = DummyEngine()
-        self.engine.setLocal('foo', MessageID('FoOvAlUe', 'default'))
-        result = StringIO()
-        self.interpreter = TALInterpreter(program, {}, self.engine,
-                                          stream=result)
-        self.interpreter()
-        self.assertEqual('<d>FOOVALUE</d>\n', result.getvalue())
-
+            '</div>')
+        self._check(program, '<div>FOOVALUE</div>\n')
 
     def test_pythonexpr_replace_with_messageid_and_i18nname(self):
         program, macros = self._compile(
-            '<d i18n:translate="" >'
+            '<div i18n:translate="" >'
             '<span tal:replace="python: foo" i18n:name="foo_name"/>'
-            '</d>')
-        self.engine = DummyEngine()
-        self.engine.setLocal('foo', MessageID('FoOvAlUe', 'default'))
-        result = StringIO()
-        self.interpreter = TALInterpreter(program, {}, self.engine,
-                                          stream=result)
-        self.interpreter()
-        self.assertEqual('<d>FOOVALUE</d>\n', result.getvalue())
-
+            '</div>')
+        self._check(program, '<div>FOOVALUE</div>\n')
 
     def test_structure_replace_with_messageid_and_i18nname(self):
         program, macros = self._compile(
-            '<d i18n:translate="" >'
+            '<div i18n:translate="" >'
             '<span tal:replace="structure foo" i18n:name="foo_name"/>'
-            '</d>')
-        self.engine = DummyEngine()
-        self.engine.setLocal('foo', MessageID('FoOvAlUe', 'default'))
-        result = StringIO()
-        self.interpreter = TALInterpreter(program, {}, self.engine,
-                                          stream=result)
-        self.interpreter()
-        self.assertEqual('<d>FOOVALUE</d>\n', result.getvalue())
-
+            '</div>')
+        self._check(program, '<div>FOOVALUE</div>\n')
 
     def test_complex_replace_with_messageid_and_i18nname(self):
         program, macros = self._compile(
@@ -134,37 +107,19 @@
             '<span tal:replace="foo"/>'
             '</em>'
             '</div>')
-        self.engine = DummyEngine()
-        self.engine.setLocal('foo', MessageID('FoOvAlUe', 'default'))
-        result = StringIO()
-        self.interpreter = TALInterpreter(program, {}, self.engine,
-                                          stream=result)
-        self.interpreter()
-        self.assertEqual('<div>FOOVALUE</div>\n', result.getvalue())
-
+        self._check(program, '<div>FOOVALUE</div>\n')
 
     def test_content_with_messageid_and_i18nname(self):
-        self.engine = DummyEngine()
-        self.engine.setLocal('foo', MessageID('FoOvAlUe', 'default'))
-
         program, macros = self._compile(
-            '<d i18n:translate="" >'
+            '<div i18n:translate="" >'
             '<span tal:content="foo" i18n:name="foo_name"/>'
-            '</d>')
-        result = StringIO()
-        self.interpreter = TALInterpreter(program, {}, self.engine,
-                                          stream=result)
-        self.interpreter()
-        self.assertEqual('<d><span>FOOVALUE</span></d>\n', result.getvalue())
+            '</div>')
+        self._check(program, '<div><span>FOOVALUE</span></div>\n')
 
         program, macros = self._compile(
             '<span i18n:translate="" tal:content="foo" i18n:name="foo_name"/>'
             )
-        result = StringIO()
-        self.interpreter = TALInterpreter(program, {}, self.engine,
-                                          stream=result)
-        self.interpreter()
-        self.assertEqual('<span>FOOVALUE</span>\n', result.getvalue())
+        self._check(program, '<span>FOOVALUE</span>\n')
 
 
 class I18NErrorsTestCase(TestCaseBase):




More information about the Zope3-Checkins mailing list