Commit 626a8e9a authored by Marc Abonce Seguin's avatar Marc Abonce Seguin
Browse files

[fix] unicode error with WolframAlpha API engine

parent 2438b3c7
...@@ -65,7 +65,7 @@ def replace_pua_chars(text): ...@@ -65,7 +65,7 @@ def replace_pua_chars(text):
def response(resp): def response(resp):
results = [] results = []
search_results = etree.XML(resp.text) search_results = etree.XML(resp.content)
# return empty array if there are no results # return empty array if there are no results
if search_results.xpath(failure_xpath): if search_results.xpath(failure_xpath):
......
...@@ -35,7 +35,7 @@ class TestWolframAlphaAPIEngine(SearxTestCase): ...@@ -35,7 +35,7 @@ class TestWolframAlphaAPIEngine(SearxTestCase):
xml = '''<?xml version='1.0' encoding='UTF-8'?> xml = '''<?xml version='1.0' encoding='UTF-8'?>
<queryresult success='false' error='false' /> <queryresult success='false' error='false' />
''' '''
response = mock.Mock(text=xml.encode('utf-8')) response = mock.Mock(content=xml.encode('utf-8'))
self.assertEqual(wolframalpha_api.response(response), []) self.assertEqual(wolframalpha_api.response(response), [])
# test basic case # test basic case
...@@ -83,7 +83,7 @@ class TestWolframAlphaAPIEngine(SearxTestCase): ...@@ -83,7 +83,7 @@ class TestWolframAlphaAPIEngine(SearxTestCase):
</pod> </pod>
</queryresult> </queryresult>
""" """
response = mock.Mock(text=xml, request=request) response = mock.Mock(content=xml, request=request)
results = wolframalpha_api.response(response) results = wolframalpha_api.response(response)
self.assertEqual(type(results), list) self.assertEqual(type(results), list)
self.assertEqual(len(results), 2) self.assertEqual(len(results), 2)
...@@ -144,7 +144,7 @@ class TestWolframAlphaAPIEngine(SearxTestCase): ...@@ -144,7 +144,7 @@ class TestWolframAlphaAPIEngine(SearxTestCase):
</pod> </pod>
</queryresult> </queryresult>
""" """
response = mock.Mock(text=xml, request=request) response = mock.Mock(content=xml, request=request)
results = wolframalpha_api.response(response) results = wolframalpha_api.response(response)
self.assertEqual(type(results), list) self.assertEqual(type(results), list)
self.assertEqual(len(results), 2) self.assertEqual(len(results), 2)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment