[ZPT] CVS: Zope/lib/python/Products/PageTemplates/tests - testHTMLTests.py:1.13.4.2

Chris McDonough chrism@zope.com
Tue, 8 Oct 2002 17:46:22 -0400


Update of /cvs-repository/Zope/lib/python/Products/PageTemplates/tests
In directory cvs.zope.org:/tmp/cvs-serv17057/lib/python/Products/PageTemplates/tests

Modified Files:
      Tag: chrism-install-branch
	testHTMLTests.py 
Log Message:
More merges from HEAD.


=== Zope/lib/python/Products/PageTemplates/tests/testHTMLTests.py 1.13.4.1 => 1.13.4.2 ===
--- Zope/lib/python/Products/PageTemplates/tests/testHTMLTests.py:1.13.4.1	Tue Sep 10 23:36:36 2002
+++ Zope/lib/python/Products/PageTemplates/tests/testHTMLTests.py	Tue Oct  8 17:45:51 2002
@@ -15,8 +15,9 @@
 
 from Products.PageTemplates.tests import util
 from Products.PageTemplates.PageTemplate import PageTemplate
-import ZODB
-from AccessControl import User, SecurityManager
+from Products.PageTemplates.GlobalTranslationService import \
+     setGlobalTranslationService
+from AccessControl import SecurityManager
 from AccessControl.SecurityManagement import noSecurityManager
 
 from Acquisition import Implicit
@@ -26,6 +27,10 @@
 class Folder(util.Base):
     pass
 
+class TestTranslationService:
+    def translate(self, domain, msgid, *args, **kw):
+        return "[%s](%s)" % (domain, msgid)
+
 
 class UnitTestSecurityPolicy:
     """
@@ -69,6 +74,14 @@
         out = apply(t, args, kwargs)
         util.check_html(expect, out)
 
+    def assert_expected_unicode(self, t, fname, *args, **kwargs):
+        t.write(util.read_input(fname))
+        assert not t._v_errors, 'Template errors: %s' % t._v_errors
+        expect = util.read_output(fname)
+        expect = unicode(expect, 'utf8')
+        out = apply(t, args, kwargs)
+        util.check_html(expect, out)
+
     def getProducts(self):
         return [
            {'description': 'This is the tee for those who LOVE Zope. '
@@ -126,8 +139,20 @@
     def checkBatchIteration(self):
         self.assert_expected(self.folder.t, 'CheckBatchIteration.html')
 
+    def checkUnicodeInserts(self):
+        self.assert_expected_unicode(self.folder.t, 'CheckUnicodeInserts.html')
+
+    def checkI18nTranslate(self):
+        self.assert_expected(self.folder.t, 'CheckI18nTranslate.html')
+
+    def checkI18nTranslateHooked(self):
+        old_ts = setGlobalTranslationService(TestTranslationService())
+        self.assert_expected(self.folder.t, 'CheckI18nTranslateHooked.html')
+        setGlobalTranslationService(old_ts)
+
 def test_suite():
     return unittest.makeSuite(HTMLTests, 'check')
 
 if __name__=='__main__':
-    unittest.main(defaultTest='test_suite')
+   main()
+