From ea10cd17e32c5e843f1c1c20ff7a097f4f04c1b5 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Fri, 9 Feb 2018 14:40:01 +0000 Subject: [PATCH] [FIX] html_text: Do not test the specific exception (#1149) Newer versions of LXML raise different exceptions. It doesn't matter, as long as there's an exception, so we move to less explicit tests. Besides, I mute the logger to avoid expected failure error logging. Newer versions also parse more wrong XML as good HTML, so a test that was expecting a failure and now doesn't is removed. --- html_text/tests/test_extractor.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/html_text/tests/test_extractor.py b/html_text/tests/test_extractor.py index 22443e32a..328b2c93a 100644 --- a/html_text/tests/test_extractor.py +++ b/html_text/tests/test_extractor.py @@ -2,8 +2,8 @@ # © 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from lxml import etree from openerp.tests.common import TransactionCase +from openerp.tools import mute_logger class ExtractorCase(TransactionCase): @@ -40,20 +40,16 @@ class ExtractorCase(TransactionCase): self.text_from_html(html, 7, ellipsis=""), u"I'm a title I'm a paragraph ¡Pues") + @mute_logger("openerp.addons.html_text.models.ir_fields_converter") def test_empty_html(self): """Empty HTML handled correctly.""" self.assertEqual(self.text_from_html(""), "") - with self.assertRaises(etree.XMLSyntaxError): + with self.assertRaises(Exception): self.text_from_html("", fail=True) + @mute_logger("openerp.addons.html_text.models.ir_fields_converter") def test_false_html(self): """``False`` HTML handled correctly.""" self.assertEqual(self.text_from_html(False), "") - with self.assertRaises(TypeError): + with self.assertRaises(Exception): self.text_from_html(False, fail=True) - - def test_bad_html(self): - """Bad HTML handled correctly.""" - self.assertEqual(self.text_from_html("<"), "") - with self.assertRaises(etree.ParserError): - self.text_from_html("<", fail=True)