Browse Source

Fix acgsou encoding error on python2 and add unicode characters to unit testt

rinpatch 6 years ago
parent
commit
059c2ccb95
No account linked to committer's email
2 changed files with 7 additions and 6 deletions
  1. 1
    1
      searx/engines/acgsou.py
  2. 6
    5
      tests/unit/engines/test_acgsou.py

+ 1
- 1
searx/engines/acgsou.py View File

63
         except:
63
         except:
64
             pass
64
             pass
65
         # I didn't add download/seed/leech count since as I figured out they are generated randomly everytime
65
         # I didn't add download/seed/leech count since as I figured out they are generated randomly everytime
66
-        content = 'Category: "{category}".'
66
+        content = u'Category: "{category}".'
67
         content = content.format(category=category)
67
         content = content.format(category=category)
68
 
68
 
69
         results.append({'url': href,
69
         results.append({'url': href,

+ 6
- 5
tests/unit/engines/test_acgsou.py View File

1
+# coding=utf-8
1
 from collections import defaultdict
2
 from collections import defaultdict
2
 import mock
3
 import mock
3
 from searx.engines import acgsou
4
 from searx.engines import acgsou
19
         resp = mock.Mock(text='<html></html>')
20
         resp = mock.Mock(text='<html></html>')
20
         self.assertEqual(acgsou.response(resp), [])
21
         self.assertEqual(acgsou.response(resp), [])
21
 
22
 
22
-        html = """
23
+        html = u"""
23
         <html>
24
         <html>
24
 <table id="listTable" class="list_style table_fixed">
25
 <table id="listTable" class="list_style table_fixed">
25
   <thead class="tcat">
26
   <thead class="tcat">
37
   <tbody class="tbody" id="data_list">
38
   <tbody class="tbody" id="data_list">
38
  <tr class="alt1 ">
39
  <tr class="alt1 ">
39
         <td nowrap="nowrap">date</td>
40
         <td nowrap="nowrap">date</td>
40
-        <td><a href="category.html">testcategory</a></td>
41
+        <td><a href="category.html">testcategory テスト</a></td>
41
         <td style="text-align:left;">
42
         <td style="text-align:left;">
42
-            <a href="show-torrentid.html" target="_blank">torrentname</a>
43
+            <a href="show-torrentid.html" target="_blank">torrentname テスト</a>
43
         </td>
44
         </td>
44
         <td>1MB</td>
45
         <td>1MB</td>
45
         <td nowrap="nowrap">
46
         <td nowrap="nowrap">
72
 
73
 
73
         r = results[0]
74
         r = results[0]
74
         self.assertEqual(r['url'], 'http://www.acgsou.com/show-torrentid.html')
75
         self.assertEqual(r['url'], 'http://www.acgsou.com/show-torrentid.html')
75
-        self.assertEqual(r['content'], 'Category: "testcategory".')
76
-        self.assertEqual(r['title'], 'torrentname')
76
+        self.assertEqual(r['content'], u'Category: "testcategory テスト".')
77
+        self.assertEqual(r['title'], u'torrentname テスト')
77
         self.assertEqual(r['filesize'], 1048576)
78
         self.assertEqual(r['filesize'], 1048576)