Selaa lähdekoodia

Merge pull request #1290 from rinpatch/acgsou-unicode

Fix acgsou encoding error on python2
Adam Tauber 6 vuotta sitten
vanhempi
commit
8a68cd2dcd
No account linked to committer's email
2 muutettua tiedostoa jossa 7 lisäystä ja 6 poistoa
  1. 1
    1
      searx/engines/acgsou.py
  2. 6
    5
      tests/unit/engines/test_acgsou.py

+ 1
- 1
searx/engines/acgsou.py Näytä tiedosto

@@ -63,7 +63,7 @@ def response(resp):
63 63
         except:
64 64
             pass
65 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 67
         content = content.format(category=category)
68 68
 
69 69
         results.append({'url': href,

+ 6
- 5
tests/unit/engines/test_acgsou.py Näytä tiedosto

@@ -1,3 +1,4 @@
1
+# coding=utf-8
1 2
 from collections import defaultdict
2 3
 import mock
3 4
 from searx.engines import acgsou
@@ -19,7 +20,7 @@ class TestAcgsouEngine(SearxTestCase):
19 20
         resp = mock.Mock(text='<html></html>')
20 21
         self.assertEqual(acgsou.response(resp), [])
21 22
 
22
-        html = """
23
+        html = u"""
23 24
         <html>
24 25
 <table id="listTable" class="list_style table_fixed">
25 26
   <thead class="tcat">
@@ -37,9 +38,9 @@ class TestAcgsouEngine(SearxTestCase):
37 38
   <tbody class="tbody" id="data_list">
38 39
  <tr class="alt1 ">
39 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 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 44
         </td>
44 45
         <td>1MB</td>
45 46
         <td nowrap="nowrap">
@@ -72,6 +73,6 @@ class TestAcgsouEngine(SearxTestCase):
72 73
 
73 74
         r = results[0]
74 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 78
         self.assertEqual(r['filesize'], 1048576)