From 3d96a9839a12649874b6d4cf9466bd3616b0a03c Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Mon, 27 Dec 2021 09:26:22 +0100 Subject: [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 --- tests/unit/test_webutils.py | 62 ++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'tests/unit/test_webutils.py') diff --git a/tests/unit/test_webutils.py b/tests/unit/test_webutils.py index 6da39a071..8bb3a0447 100644 --- a/tests/unit/test_webutils.py +++ b/tests/unit/test_webutils.py @@ -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 = [ - '' - 'not<' - ] + contents = ['' '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 test string'), - ('"a"', - 'this is a test string', - 'this is a test string'), - ('a test', - 'this is a test string that matches entire query', - 'this is a test string that matches entire query'), - ('this a test', - 'this is a string to test.', - ('this is a ' - 'string to test.')), - ('match this "exact phrase"', - 'this string contains the exact phrase we want to match', - ('this string contains the exact' - ' phrase we want to match')) + ('" test "', 'a test string', 'a test string'), + ('"a"', 'this is a test string', 'this is a test string'), + ( + 'a test', + 'this is a test string that matches entire query', + 'this is a test string that matches entire query', + ), + ( + 'this a test', + 'this is a string to test.', + ( + 'this is a ' + 'string to test.' + ), + ), + ( + 'match this "exact phrase"', + 'this string contains the exact phrase we want to match', + ( + 'this string contains the exact' + ' phrase we want to match' + ), + ), ) 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') -- cgit v1.2.3 From d84226bf63757b1d4245ab26e9c081daf42389aa Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Mon, 27 Dec 2021 10:16:20 +0100 Subject: [fix] issues reported by pylint Fix pylint issues from commit (3d96a983) [format.python] initial formatting of the python code Signed-off-by: Markus Heiser --- tests/unit/test_webutils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/unit/test_webutils.py') diff --git a/tests/unit/test_webutils.py b/tests/unit/test_webutils.py index 8bb3a0447..2b7c6fe5a 100644 --- a/tests/unit/test_webutils.py +++ b/tests/unit/test_webutils.py @@ -22,7 +22,7 @@ class TestWebUtils(SearxTestCase): self.assertEqual(webutils.highlight_content('', None), None) self.assertEqual(webutils.highlight_content(False, None), None) - contents = ['' 'not<'] + contents = ['not<'] for content in contents: self.assertEqual(webutils.highlight_content(content, None), content) -- cgit v1.2.3