mirror of
https://github.com/searxng/searxng.git
synced 2025-07-19 03:09:25 +02:00
[format.python] initial formatting of the python code
This patch was generated by black [1]:: make format.python [1] https://github.com/psf/black Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
fcdc2c2cd2
commit
3d96a9839a
184 changed files with 2800 additions and 2836 deletions
|
@ -5,12 +5,13 @@ from tests import SearxTestCase
|
|||
|
||||
|
||||
class TestWebUtils(SearxTestCase):
|
||||
|
||||
def test_prettify_url(self):
|
||||
data = (('https://searx.me/', 'https://searx.me/'),
|
||||
('https://searx.me/ű', 'https://searx.me/ű'),
|
||||
('https://searx.me/' + (100 * 'a'), 'https://searx.me/[...]aaaaaaaaaaaaaaaaa'),
|
||||
('https://searx.me/' + (100 * 'ű'), 'https://searx.me/[...]űűűűűűűűűűűűűűűűű'))
|
||||
data = (
|
||||
('https://searx.me/', 'https://searx.me/'),
|
||||
('https://searx.me/ű', 'https://searx.me/ű'),
|
||||
('https://searx.me/' + (100 * 'a'), 'https://searx.me/[...]aaaaaaaaaaaaaaaaa'),
|
||||
('https://searx.me/' + (100 * 'ű'), 'https://searx.me/[...]űűűűűűűűűűűűűűűűű'),
|
||||
)
|
||||
|
||||
for test_url, expected in data:
|
||||
self.assertEqual(webutils.prettify_url(test_url, max_length=32), expected)
|
||||
|
@ -21,10 +22,7 @@ class TestWebUtils(SearxTestCase):
|
|||
self.assertEqual(webutils.highlight_content('', None), None)
|
||||
self.assertEqual(webutils.highlight_content(False, None), None)
|
||||
|
||||
contents = [
|
||||
'<html></html>'
|
||||
'not<'
|
||||
]
|
||||
contents = ['<html></html>' 'not<']
|
||||
for content in contents:
|
||||
self.assertEqual(webutils.highlight_content(content, None), content)
|
||||
|
||||
|
@ -35,30 +33,35 @@ class TestWebUtils(SearxTestCase):
|
|||
self.assertEqual(webutils.highlight_content(content, query), content)
|
||||
|
||||
data = (
|
||||
('" test "',
|
||||
'a test string',
|
||||
'a <span class="highlight">test</span> string'),
|
||||
('"a"',
|
||||
'this is a test string',
|
||||
'this is<span class="highlight"> a </span>test string'),
|
||||
('a test',
|
||||
'this is a test string that matches entire query',
|
||||
'this is <span class="highlight">a test</span> string that matches entire query'),
|
||||
('this a test',
|
||||
'this is a string to test.',
|
||||
('<span class="highlight">this</span> is<span class="highlight"> a </span>'
|
||||
'string to <span class="highlight">test</span>.')),
|
||||
('match this "exact phrase"',
|
||||
'this string contains the exact phrase we want to match',
|
||||
('<span class="highlight">this</span> string contains the <span class="highlight">exact</span>'
|
||||
' <span class="highlight">phrase</span> we want to <span class="highlight">match</span>'))
|
||||
('" test "', 'a test string', 'a <span class="highlight">test</span> string'),
|
||||
('"a"', 'this is a test string', 'this is<span class="highlight"> a </span>test string'),
|
||||
(
|
||||
'a test',
|
||||
'this is a test string that matches entire query',
|
||||
'this is <span class="highlight">a test</span> string that matches entire query',
|
||||
),
|
||||
(
|
||||
'this a test',
|
||||
'this is a string to test.',
|
||||
(
|
||||
'<span class="highlight">this</span> is<span class="highlight"> a </span>'
|
||||
'string to <span class="highlight">test</span>.'
|
||||
),
|
||||
),
|
||||
(
|
||||
'match this "exact phrase"',
|
||||
'this string contains the exact phrase we want to match',
|
||||
(
|
||||
'<span class="highlight">this</span> string contains the <span class="highlight">exact</span>'
|
||||
' <span class="highlight">phrase</span> we want to <span class="highlight">match</span>'
|
||||
),
|
||||
),
|
||||
)
|
||||
for query, content, expected in data:
|
||||
self.assertEqual(webutils.highlight_content(content, query), expected)
|
||||
|
||||
|
||||
class TestUnicodeWriter(SearxTestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.unicode_writer = webutils.UnicodeWriter(mock.MagicMock())
|
||||
|
||||
|
@ -74,7 +77,6 @@ class TestUnicodeWriter(SearxTestCase):
|
|||
|
||||
|
||||
class TestNewHmac(SearxTestCase):
|
||||
|
||||
def test_bytes(self):
|
||||
for secret_key in ['secret', b'secret', 1]:
|
||||
if secret_key == 1:
|
||||
|
@ -82,6 +84,4 @@ class TestNewHmac(SearxTestCase):
|
|||
webutils.new_hmac(secret_key, b'http://example.com')
|
||||
continue
|
||||
res = webutils.new_hmac(secret_key, b'http://example.com')
|
||||
self.assertEqual(
|
||||
res,
|
||||
'23e2baa2404012a5cc8e4a18b4aabf0dde4cb9b56f679ddc0fd6d7c24339d819')
|
||||
self.assertEqual(res, '23e2baa2404012a5cc8e4a18b4aabf0dde4cb9b56f679ddc0fd6d7c24339d819')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue