瀏覽代碼

minor fix of BASE engine

Noémi Ványi 7 年之前
父節點
當前提交
5954a8e16a
共有 2 個檔案被更改,包括 4 行新增4 行删除
  1. 1
    1
      searx/engines/base.py
  2. 3
    3
      tests/unit/engines/test_base.py

+ 1
- 1
searx/engines/base.py 查看文件

@@ -73,7 +73,7 @@ def request(query, params):
73 73
 def response(resp):
74 74
     results = []
75 75
 
76
-    search_results = etree.XML(resp.text)
76
+    search_results = etree.XML(resp.content)
77 77
 
78 78
     for entry in search_results.xpath('./result/doc'):
79 79
         content = "No description available"

+ 3
- 3
tests/unit/engines/test_base.py 查看文件

@@ -21,10 +21,10 @@ class TestBaseEngine(SearxTestCase):
21 21
         self.assertRaises(AttributeError, base.response, '')
22 22
         self.assertRaises(AttributeError, base.response, '[]')
23 23
 
24
-        response = mock.Mock(text='<response></response>')
24
+        response = mock.Mock(content=b'<response></response>')
25 25
         self.assertEqual(base.response(response), [])
26 26
 
27
-        xml_mock = """<?xml version="1.0"?>
27
+        xml_mock = b"""<?xml version="1.0"?>
28 28
 <response>
29 29
   <lst name="responseHeader">
30 30
     <int name="status">0</int>
@@ -83,7 +83,7 @@ class TestBaseEngine(SearxTestCase):
83 83
   </result>
84 84
 </response>"""
85 85
 
86
-        response = mock.Mock(text=xml_mock.encode('utf-8'))
86
+        response = mock.Mock(content=xml_mock)
87 87
         results = base.response(response)
88 88
         self.assertEqual(type(results), list)
89 89
         self.assertEqual(len(results), 1)