From 5954a8e16a64a369072a7487f62b6396a451ae5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=83=C2=A9mi=20V=C3=83=C2=A1nyi?= Date: Wed, 1 Nov 2017 16:50:27 +0100 Subject: [PATCH] minor fix of BASE engine --- searx/engines/base.py | 2 +- tests/unit/engines/test_base.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/searx/engines/base.py b/searx/engines/base.py index ff006a3bc..be0b7d247 100755 --- a/searx/engines/base.py +++ b/searx/engines/base.py @@ -73,7 +73,7 @@ def request(query, params): def response(resp): results = [] - search_results = etree.XML(resp.text) + search_results = etree.XML(resp.content) for entry in search_results.xpath('./result/doc'): content = "No description available" diff --git a/tests/unit/engines/test_base.py b/tests/unit/engines/test_base.py index e008b034c..b5da5bde7 100644 --- a/tests/unit/engines/test_base.py +++ b/tests/unit/engines/test_base.py @@ -21,10 +21,10 @@ class TestBaseEngine(SearxTestCase): self.assertRaises(AttributeError, base.response, '') self.assertRaises(AttributeError, base.response, '[]') - response = mock.Mock(text='') + response = mock.Mock(content=b'') self.assertEqual(base.response(response), []) - xml_mock = """ + xml_mock = b""" 0 @@ -83,7 +83,7 @@ class TestBaseEngine(SearxTestCase): """ - response = mock.Mock(text=xml_mock.encode('utf-8')) + response = mock.Mock(content=xml_mock) results = base.response(response) self.assertEqual(type(results), list) self.assertEqual(len(results), 1)