[Erp5-report] r32265 leonardo - /erp5/trunk/products/ERP5/tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Feb 4 15:29:12 CET 2010


Author: leonardo
Date: Thu Feb  4 15:29:12 2010
New Revision: 32265

URL: http://svn.erp5.org?rev=32265&view=rev
Log:
fix testContenTranslation errors on Zope 2.12 by converting ZPT results from unicode to utf-8

Modified:
    erp5/trunk/products/ERP5/tests/testContentTranslation.py
    erp5/trunk/products/ERP5/tests/testEditorField.py

Modified: erp5/trunk/products/ERP5/tests/testContentTranslation.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testContentTranslation.py?rev=32265&r1=32264&r2=32265&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testContentTranslation.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testContentTranslation.py [utf8] Thu Feb  4 15:29:12 2010
@@ -27,6 +27,7 @@
 ##############################################################################
 import unittest
 from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
+from Products.ERP5Type.tests.utils import to_utf8
 import transaction
 
 
@@ -102,8 +103,8 @@
     transaction.commit()
     self.tic()
 
-    self.assert_('タハラ' in person.Base_viewContentTranslation())
-    self.assert_('ユウセイ' in person.Base_viewContentTranslation())
+    self.assert_('タハラ' in to_utf8(person.Base_viewContentTranslation()))
+    self.assert_('ユウセイ' in to_utf8(person.Base_viewContentTranslation()))
 
     self.assertEqual(person.getJaKanaTranslatedFirstName(), 'タハラ')
     self.assertEqual(person.getJaKanaTranslatedLastName(), 'ユウセイ')

Modified: erp5/trunk/products/ERP5/tests/testEditorField.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testEditorField.py?rev=32265&r1=32264&r2=32265&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testEditorField.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testEditorField.py [utf8] Thu Feb  4 15:29:12 2010
@@ -35,6 +35,7 @@
 from AccessControl.SecurityManagement import newSecurityManager
 from Testing import ZopeTestCase
 from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
+from Products.ERP5Type.tests.utils import to_utf8
 
 class TestEditorField(ERP5TypeTestCase, ZopeTestCase.Functional):
   """
@@ -93,15 +94,6 @@
   def getDefaultSitePreference(self):
     return self.getPreferenceTool().default_site_preference
 
-  def _fromUnicode(self, html_text):
-    """
-    ZPTs in Zope 2.12 render to unicode. Here we normalize to utf-8
-    """
-    # XXX: We should consider switching ERP5 to Unicode instead.
-    if isinstance(html_text, unicode):
-      html_text = html_text.encode('utf-8')
-    return html_text
-
   def _testPreferredDocumentEditor(self, event, preferred_editor, editor, form_id, field_id):
     """
       Common code to test if current document (event)
@@ -135,7 +127,7 @@
 
       text_content -- the embedded text content
     """
-    html_text = self._fromUnicode(html_text)
+    html_text = to_utf8(html_text)
     match_string1 = "var oFCKeditor      = new FCKeditor('field_%s');" % field_id
     match_string2 = "oFCKeditor.Value    = '%s';" % ('\\n'.join(text_content.splitlines()))
     if html_text.find(match_string1) == -1:
@@ -160,7 +152,7 @@
 
       text_content -- the embedded text content
     """
-    html_text = self._fromUnicode(html_text)
+    html_text = to_utf8(html_text)
     match_string = """name="field_%s" >%s</textarea>""" % (field_id, text_content)
     if html_text.find(match_string) == -1:
       print html_text
@@ -179,7 +171,7 @@
       document -- the document which content is displayed in 
                   read only mode
     """
-    html_text = self._fromUnicode(html_text)
+    html_text = to_utf8(html_text)
     text_content = document.asStrippedHTML()
     match_string1 = """<div class="input">%s</div>""" % text_content
     match_string2 = """<div class="field page"""




More information about the Erp5-report mailing list