From 059c2ccb9576f8aae36b4e1c0bf6a024d75701ea Mon Sep 17 00:00:00 2001 From: rinpatch Date: Sat, 5 May 2018 23:41:13 +0300 Subject: [PATCH] Fix acgsou encoding error on python2 and add unicode characters to unit testt --- searx/engines/acgsou.py | 2 +- tests/unit/engines/test_acgsou.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/searx/engines/acgsou.py b/searx/engines/acgsou.py index c82379c27..cca28f0db 100644 --- a/searx/engines/acgsou.py +++ b/searx/engines/acgsou.py @@ -63,7 +63,7 @@ def response(resp): except: pass # I didn't add download/seed/leech count since as I figured out they are generated randomly everytime - content = 'Category: "{category}".' + content = u'Category: "{category}".' content = content.format(category=category) results.append({'url': href, diff --git a/tests/unit/engines/test_acgsou.py b/tests/unit/engines/test_acgsou.py index f97749cc1..c01acf5de 100644 --- a/tests/unit/engines/test_acgsou.py +++ b/tests/unit/engines/test_acgsou.py @@ -1,3 +1,4 @@ +# coding=utf-8 from collections import defaultdict import mock from searx.engines import acgsou @@ -19,7 +20,7 @@ class TestAcgsouEngine(SearxTestCase): resp = mock.Mock(text='') self.assertEqual(acgsou.response(resp), []) - html = """ + html = u""" @@ -37,9 +38,9 @@ class TestAcgsouEngine(SearxTestCase): - +
datetestcategorytestcategory テスト - torrentname + torrentname テスト 1MB @@ -72,6 +73,6 @@ class TestAcgsouEngine(SearxTestCase): r = results[0] self.assertEqual(r['url'], 'http://www.acgsou.com/show-torrentid.html') - self.assertEqual(r['content'], 'Category: "testcategory".') - self.assertEqual(r['title'], 'torrentname') + self.assertEqual(r['content'], u'Category: "testcategory テスト".') + self.assertEqual(r['title'], u'torrentname テスト') self.assertEqual(r['filesize'], 1048576)