Fix Zope 2.12 breakages on testEditorField, along with commit #31588, as soon...

Fix Zope 2.12 breakages on testEditorField, along with commit #31588, as soon as the fix for https://bugs.launchpad.net/zope2/+bug/246983 is applied on Zope 2.12

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31589 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 50fdee41
......@@ -93,6 +93,15 @@ class TestEditorField(ERP5TypeTestCase, ZopeTestCase.Functional):
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)
......@@ -126,6 +135,7 @@ class TestEditorField(ERP5TypeTestCase, ZopeTestCase.Functional):
text_content -- the embedded text content
"""
html_text = self._fromUnicode(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:
......@@ -150,6 +160,7 @@ class TestEditorField(ERP5TypeTestCase, ZopeTestCase.Functional):
text_content -- the embedded text content
"""
html_text = self._fromUnicode(html_text)
match_string = """name="field_%s" >%s</textarea>""" % (field_id, text_content)
if html_text.find(match_string) == -1:
print html_text
......@@ -168,6 +179,7 @@ class TestEditorField(ERP5TypeTestCase, ZopeTestCase.Functional):
document -- the document which content is displayed in
read only mode
"""
html_text = self._fromUnicode(html_text)
text_content = document.asStrippedHTML()
match_string1 = """<div class="input">%s</div>""" % text_content
match_string2 = """<div class="field page"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment