diff options
author | Noémi Ványi <sitbackandwait@gmail.com> | 2017-11-01 16:50:27 +0100 |
---|---|---|
committer | Noémi Ványi <sitbackandwait@gmail.com> | 2017-11-01 17:02:38 +0100 |
commit | 5954a8e16a64a369072a7487f62b6396a451ae5f (patch) | |
tree | 3931e34b8501cd58db58cb651b0193ee46c23eb8 | |
parent | d20bba6dc74ded16556acf2a404d01ec47455ca6 (diff) | |
download | searxng-5954a8e16a64a369072a7487f62b6396a451ae5f.tar.gz searxng-5954a8e16a64a369072a7487f62b6396a451ae5f.zip |
minor fix of BASE engine
-rwxr-xr-x | searx/engines/base.py | 2 | ||||
-rw-r--r-- | 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></response>') + response = mock.Mock(content=b'<response></response>') self.assertEqual(base.response(response), []) - xml_mock = """<?xml version="1.0"?> + xml_mock = b"""<?xml version="1.0"?> <response> <lst name="responseHeader"> <int name="status">0</int> @@ -83,7 +83,7 @@ class TestBaseEngine(SearxTestCase): </result> </response>""" - 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) |