From 626a8e9ac923886ea368a621a7711f09fa59da56 Mon Sep 17 00:00:00 2001 From: Marc Abonce Seguin Date: Tue, 8 Jan 2019 20:22:16 -0600 Subject: [PATCH] [fix] unicode error with WolframAlpha API engine --- searx/engines/wolframalpha_api.py | 2 +- tests/unit/engines/test_wolframalpha_api.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/searx/engines/wolframalpha_api.py b/searx/engines/wolframalpha_api.py index 595c6b7de..1c58c4a9b 100644 --- a/searx/engines/wolframalpha_api.py +++ b/searx/engines/wolframalpha_api.py @@ -65,7 +65,7 @@ def replace_pua_chars(text): def response(resp): results = [] - search_results = etree.XML(resp.text) + search_results = etree.XML(resp.content) # return empty array if there are no results if search_results.xpath(failure_xpath): diff --git a/tests/unit/engines/test_wolframalpha_api.py b/tests/unit/engines/test_wolframalpha_api.py index 30d337645..0433b34aa 100644 --- a/tests/unit/engines/test_wolframalpha_api.py +++ b/tests/unit/engines/test_wolframalpha_api.py @@ -35,7 +35,7 @@ class TestWolframAlphaAPIEngine(SearxTestCase): xml = ''' ''' - response = mock.Mock(text=xml.encode('utf-8')) + response = mock.Mock(content=xml.encode('utf-8')) self.assertEqual(wolframalpha_api.response(response), []) # test basic case @@ -83,7 +83,7 @@ class TestWolframAlphaAPIEngine(SearxTestCase): """ - response = mock.Mock(text=xml, request=request) + response = mock.Mock(content=xml, request=request) results = wolframalpha_api.response(response) self.assertEqual(type(results), list) self.assertEqual(len(results), 2) @@ -144,7 +144,7 @@ class TestWolframAlphaAPIEngine(SearxTestCase): """ - response = mock.Mock(text=xml, request=request) + response = mock.Mock(content=xml, request=request) results = wolframalpha_api.response(response) self.assertEqual(type(results), list) self.assertEqual(len(results), 2)