diff --git a/openerp/addons/base/tests/test_translate.py b/openerp/addons/base/tests/test_translate.py index 40cf960873c..95b306e1837 100644 --- a/openerp/addons/base/tests/test_translate.py +++ b/openerp/addons/base/tests/test_translate.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +from lxml.etree import XMLSyntaxError import unittest from openerp.tools.translate import quote, unquote, xml_translate, html_translate @@ -41,6 +42,29 @@ class TranslationToolsTestCase(unittest.TestCase): self.assertItemsEqual(terms, ['Form stuff', 'Blah blah blah', 'Put some more text here']) + def test_translate_xml_text(self): + """ Test xml_translate() on plain text. """ + terms = [] + source = "Blah blah blah" + result = xml_translate(terms.append, source) + self.assertEquals(result, source) + self.assertItemsEqual(terms, [source]) + + def test_translate_xml_text_entity_unescaped(self): + """ Test xml_translate() on plain text with HTML entities. """ + terms = [] + source = "Blah blah blah" + with self.assertRaises(XMLSyntaxError): + xml_translate(terms.append, source) + + def test_translate_xml_text_entity(self): + """ Test xml_translate() on plain text with HTML escaped entities. """ + terms = [] + source = "Blah blah blah" + result = xml_translate(terms.append, source) + self.assertEquals(result, source) + self.assertItemsEqual(terms, [source]) + def test_translate_xml_inline1(self): """ Test xml_translate() with formatting elements. """ terms = [] diff --git a/openerp/tools/translate.py b/openerp/tools/translate.py index 3287547c790..07b587d1467 100644 --- a/openerp/tools/translate.py +++ b/openerp/tools/translate.py @@ -286,8 +286,7 @@ def html_translate(callback, value): trans = XMLTranslator(callback, 'html') wrapped = "