on master help sign in
Merge pull request #1290 from rinpatch/acgsou-unicode

Fix acgsou encoding error on python2

commit8a68cd2dcd6ec3116c6086300a3380f9d9a4f735 authorAdam Tauber <asciimoo@gmail.com> dateSun 6 May 2018, 18:28 (8 years ago) parent5897343059c2cc
2 files changed+7−6
searx/engines/acgsou.py+1−1 tests/unit/engines/test_acgsou.py+6−5
searx/engines/acgsou.py+1−1
@@ -63,7 +63,7 @@ def response(resp):
6363 except:
6464 pass
6565 # 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}".'
6767 content = content.format(category=category)
6868
6969 results.append({'url': href,
tests/unit/engines/test_acgsou.py+6−5
@@ -1,3 +1,4 @@
1+# coding=utf-8
12from collections import defaultdict
23import mock
34from searx.engines import acgsou
@@ -19,7 +20,7 @@ class TestAcgsouEngine(SearxTestCase):
1920 resp = mock.Mock(text='<html></html>')
2021 self.assertEqual(acgsou.response(resp), [])
2122
22− html = """
23+ html = u"""
2324 <html>
2425<table id="listTable" class="list_style table_fixed">
2526 <thead class="tcat">
@@ -37,9 +38,9 @@ class TestAcgsouEngine(SearxTestCase):
3738 <tbody class="tbody" id="data_list">
3839 <tr class="alt1 ">
3940 <td nowrap="nowrap">date</td>
40− <td><a href="category.html">testcategory</a></td>
41+ <td><a href="category.html">testcategory テスト</a></td>
4142 <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>
4344 </td>
4445 <td>1MB</td>
4546 <td nowrap="nowrap">
@@ -72,6 +73,6 @@ class TestAcgsouEngine(SearxTestCase):
7273
7374 r = results[0]
7475 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 テスト')
7778 self.assertEqual(r['filesize'], 1048576)