summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/__init__.py4
-rw-r--r--tests/robot/__init__.py2
-rw-r--r--tests/robot/__main__.py1
-rw-r--r--tests/robot/test_webapp.py1
-rw-r--r--tests/unit/__init__.py3
-rw-r--r--tests/unit/engines/test_command.py3
-rw-r--r--tests/unit/engines/test_xpath.py4
-rw-r--r--tests/unit/network/__init__.py2
-rw-r--r--tests/unit/network/test_network.py15
-rw-r--r--tests/unit/test_answerers.py5
-rw-r--r--tests/unit/test_engines_init.py13
-rw-r--r--tests/unit/test_exceptions.py3
-rw-r--r--tests/unit/test_external_bangs.py13
-rw-r--r--tests/unit/test_locales.py3
-rw-r--r--tests/unit/test_plugins.py16
-rw-r--r--tests/unit/test_preferences.py11
-rw-r--r--tests/unit/test_query.py13
-rw-r--r--tests/unit/test_results.py6
-rw-r--r--tests/unit/test_search.py9
-rw-r--r--tests/unit/test_settings_loader.py7
-rw-r--r--tests/unit/test_utils.py18
-rw-r--r--tests/unit/test_webadapter.py11
-rw-r--r--tests/unit/test_webapp.py16
-rw-r--r--tests/unit/test_webutils.py11
24 files changed, 114 insertions, 76 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
index 8399f0604..2ccc51847 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -1,5 +1,7 @@
-import os
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
+import os
import aiounittest
os.environ.pop('SEARX_DEBUG', None)
diff --git a/tests/robot/__init__.py b/tests/robot/__init__.py
index e69de29bb..f7378de06 100644
--- a/tests/robot/__init__.py
+++ b/tests/robot/__init__.py
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring, cyclic-import
diff --git a/tests/robot/__main__.py b/tests/robot/__main__.py
index 758a521ee..20b15ef04 100644
--- a/tests/robot/__main__.py
+++ b/tests/robot/__main__.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
"""Shared testing code."""
# pylint: disable=missing-function-docstring
diff --git a/tests/robot/test_webapp.py b/tests/robot/test_webapp.py
index 42066e37a..fecbf53f0 100644
--- a/tests/robot/test_webapp.py
+++ b/tests/robot/test_webapp.py
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
# pylint: disable=missing-module-docstring,missing-function-docstring
from time import sleep
diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py
index 9094e836a..e43c93f1c 100644
--- a/tests/unit/__init__.py
+++ b/tests/unit/__init__.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
+
import os
from os.path import dirname, sep, abspath
diff --git a/tests/unit/engines/test_command.py b/tests/unit/engines/test_command.py
index fa29c4e3f..a7d2d2d56 100644
--- a/tests/unit/engines/test_command.py
+++ b/tests/unit/engines/test_command.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
+
'''
searx is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
diff --git a/tests/unit/engines/test_xpath.py b/tests/unit/engines/test_xpath.py
index e616ff025..24f14127b 100644
--- a/tests/unit/engines/test_xpath.py
+++ b/tests/unit/engines/test_xpath.py
@@ -1,4 +1,6 @@
-# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
+
from collections import defaultdict
import mock
from searx.engines import xpath
diff --git a/tests/unit/network/__init__.py b/tests/unit/network/__init__.py
index e69de29bb..9ed59c825 100644
--- a/tests/unit/network/__init__.py
+++ b/tests/unit/network/__init__.py
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
diff --git a/tests/unit/network/test_network.py b/tests/unit/network/test_network.py
index 905b981c1..eabb23082 100644
--- a/tests/unit/network/test_network.py
+++ b/tests/unit/network/test_network.py
@@ -1,4 +1,5 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring, protected-access
from mock import patch
@@ -8,7 +9,7 @@ from searx.network.network import Network, NETWORKS, initialize
from tests import SearxTestCase
-class TestNetwork(SearxTestCase):
+class TestNetwork(SearxTestCase): # pylint: disable=missing-class-docstring
def setUp(self):
initialize()
@@ -121,7 +122,7 @@ class TestNetwork(SearxTestCase):
await network.aclose()
-class TestNetworkRequestRetries(SearxTestCase):
+class TestNetworkRequestRetries(SearxTestCase): # pylint: disable=missing-class-docstring
TEXT = 'Lorem Ipsum'
@@ -129,7 +130,7 @@ class TestNetworkRequestRetries(SearxTestCase):
def get_response_404_then_200(cls):
first = True
- async def get_response(*args, **kwargs):
+ async def get_response(*args, **kwargs): # pylint: disable=unused-argument
nonlocal first
if first:
first = False
@@ -169,7 +170,7 @@ class TestNetworkRequestRetries(SearxTestCase):
async def test_retries_exception_then_200(self):
request_count = 0
- async def get_response(*args, **kwargs):
+ async def get_response(*args, **kwargs): # pylint: disable=unused-argument
nonlocal request_count
request_count += 1
if request_count < 3:
@@ -194,7 +195,7 @@ class TestNetworkRequestRetries(SearxTestCase):
await network.aclose()
-class TestNetworkStreamRetries(SearxTestCase):
+class TestNetworkStreamRetries(SearxTestCase): # pylint: disable=missing-class-docstring
TEXT = 'Lorem Ipsum'
@@ -202,7 +203,7 @@ class TestNetworkStreamRetries(SearxTestCase):
def get_response_exception_then_200(cls):
first = True
- def stream(*args, **kwargs):
+ def stream(*args, **kwargs): # pylint: disable=unused-argument
nonlocal first
if first:
first = False
@@ -228,7 +229,7 @@ class TestNetworkStreamRetries(SearxTestCase):
async def test_retries_exception(self):
first = True
- def stream(*args, **kwargs):
+ def stream(*args, **kwargs): # pylint: disable=unused-argument
nonlocal first
if first:
first = False
diff --git a/tests/unit/test_answerers.py b/tests/unit/test_answerers.py
index 73148f327..e96e20c3c 100644
--- a/tests/unit/test_answerers.py
+++ b/tests/unit/test_answerers.py
@@ -1,4 +1,5 @@
-# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
from mock import Mock
@@ -6,7 +7,7 @@ from searx.answerers import answerers
from tests import SearxTestCase
-class AnswererTest(SearxTestCase):
+class AnswererTest(SearxTestCase): # pylint: disable=missing-class-docstring
def test_unicode_input(self):
query = Mock()
unicode_payload = 'árvíztűrő tükörfúrógép'
diff --git a/tests/unit/test_engines_init.py b/tests/unit/test_engines_init.py
index 2844569d1..4872a1b1b 100644
--- a/tests/unit/test_engines_init.py
+++ b/tests/unit/test_engines_init.py
@@ -1,8 +1,11 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
+
from searx import settings, engines
from tests import SearxTestCase
-class TestEnginesInit(SearxTestCase):
+class TestEnginesInit(SearxTestCase): # pylint: disable=missing-class-docstring
@classmethod
def tearDownClass(cls):
settings['outgoing']['using_tor_proxy'] = False
@@ -19,7 +22,7 @@ class TestEnginesInit(SearxTestCase):
self.assertIn('engine1', engines.engines)
self.assertIn('engine2', engines.engines)
- def test_initialize_engines_exclude_onions(self):
+ def test_initialize_engines_exclude_onions(self): # pylint: disable=invalid-name
settings['outgoing']['using_tor_proxy'] = False
engine_list = [
{'engine': 'dummy', 'name': 'engine1', 'shortcut': 'e1', 'categories': 'general'},
@@ -31,7 +34,7 @@ class TestEnginesInit(SearxTestCase):
self.assertIn('engine1', engines.engines)
self.assertNotIn('onions', engines.categories)
- def test_initialize_engines_include_onions(self):
+ def test_initialize_engines_include_onions(self): # pylint: disable=invalid-name
settings['outgoing']['using_tor_proxy'] = True
settings['outgoing']['extra_proxy_timeout'] = 100.0
engine_list = [
@@ -59,7 +62,7 @@ class TestEnginesInit(SearxTestCase):
engine_list = [
{'engine': 'dummy', 'shortcut': 'e1', 'categories': 'general'},
]
- with self.assertLogs('searx.engines', level='ERROR') as cm:
+ with self.assertLogs('searx.engines', level='ERROR') as cm: # pylint: disable=invalid-name
engines.load_engines(engine_list)
self.assertEqual(len(engines.engines), 0)
self.assertEqual(cm.output, ['ERROR:searx.engines:An engine does not have a "name" field'])
@@ -69,7 +72,7 @@ class TestEnginesInit(SearxTestCase):
engine_list = [
{'name': 'engine2', 'shortcut': 'e2', 'categories': 'onions'},
]
- with self.assertLogs('searx.engines', level='ERROR') as cm:
+ with self.assertLogs('searx.engines', level='ERROR') as cm: # pylint: disable=invalid-name
engines.load_engines(engine_list)
self.assertEqual(len(engines.engines), 0)
self.assertEqual(
diff --git a/tests/unit/test_exceptions.py b/tests/unit/test_exceptions.py
index 13d004322..514b9ce1f 100644
--- a/tests/unit/test_exceptions.py
+++ b/tests/unit/test_exceptions.py
@@ -1,11 +1,12 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
from tests import SearxTestCase
import searx.exceptions
from searx import get_setting
-class TestExceptions(SearxTestCase):
+class TestExceptions(SearxTestCase): # pylint: disable=missing-class-docstring
def test_default_suspend_time(self):
with self.assertRaises(searx.exceptions.SearxEngineAccessDeniedException) as e:
raise searx.exceptions.SearxEngineAccessDeniedException()
diff --git a/tests/unit/test_external_bangs.py b/tests/unit/test_external_bangs.py
index 794edf159..ad20d52f7 100644
--- a/tests/unit/test_external_bangs.py
+++ b/tests/unit/test_external_bangs.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
+
from searx.external_bang import (
get_node,
resolve_bang_definition,
@@ -31,9 +34,9 @@ TEST_DB = {
}
-class TestGetNode(SearxTestCase):
+class TestGetNode(SearxTestCase): # pylint: disable=missing-class-docstring
- DB = {
+ DB = { # pylint:disable=invalid-name
'trie': {
'exam': {
'ple': 'test',
@@ -62,7 +65,7 @@ class TestGetNode(SearxTestCase):
self.assertEqual(after, 's')
-class TestResolveBangDefinition(SearxTestCase):
+class TestResolveBangDefinition(SearxTestCase): # pylint:disable=missing-class-docstring
def test_https(self):
url, rank = resolve_bang_definition('//example.com/' + chr(2) + chr(1) + '42', 'query')
self.assertEqual(url, 'https://example.com/query')
@@ -74,7 +77,7 @@ class TestResolveBangDefinition(SearxTestCase):
self.assertEqual(rank, 0)
-class TestGetBangDefinitionAndAutocomplete(SearxTestCase):
+class TestGetBangDefinitionAndAutocomplete(SearxTestCase): # pylint:disable=missing-class-docstring
def test_found(self):
bang_definition, new_autocomplete = get_bang_definition_and_autocomplete('exam', external_bangs_db=TEST_DB)
self.assertEqual(bang_definition, TEST_DB['trie']['exam'][LEAF_KEY])
@@ -106,7 +109,7 @@ class TestGetBangDefinitionAndAutocomplete(SearxTestCase):
self.assertEqual(new_autocomplete, [])
-class TestExternalBangJson(SearxTestCase):
+class TestExternalBangJson(SearxTestCase): # pylint:disable=missing-class-docstring
def test_no_external_bang_query(self):
result = get_bang_url(SearchQuery('test', engineref_list=[EngineRef('wikipedia', 'general')]))
self.assertEqual(result, None)
diff --git a/tests/unit/test_locales.py b/tests/unit/test_locales.py
index e18353145..6407a5761 100644
--- a/tests/unit/test_locales.py
+++ b/tests/unit/test_locales.py
@@ -1,6 +1,5 @@
-# -*- coding: utf-8 -*-
# SPDX-License-Identifier: AGPL-3.0-or-later
-# lint: pylint
+# pylint: disable=missing-module-docstring
"""Test some code from module :py:obj:`searx.locales`"""
from searx import locales
diff --git a/tests/unit/test_plugins.py b/tests/unit/test_plugins.py
index 90436266e..a5a2f0471 100644
--- a/tests/unit/test_plugins.py
+++ b/tests/unit/test_plugins.py
@@ -1,4 +1,7 @@
-# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
+
+from mock import Mock
from searx import (
plugins,
@@ -6,21 +9,20 @@ from searx import (
botdetection,
)
-from mock import Mock
from tests import SearxTestCase
def get_search_mock(query, **kwargs):
- return Mock(search_query=Mock(query=query, **kwargs), result_container=Mock(answers=dict()))
+ return Mock(search_query=Mock(query=query, **kwargs), result_container=Mock(answers={}))
-class PluginMock:
+class PluginMock: # pylint: disable=missing-class-docstring, too-few-public-methods
default_on = False
name = 'Default plugin'
description = 'Default plugin description'
-class PluginStoreTest(SearxTestCase):
+class PluginStoreTest(SearxTestCase): # pylint: disable=missing-class-docstring
def test_PluginStore_init(self):
store = plugins.PluginStore()
self.assertTrue(isinstance(store.plugins, list) and len(store.plugins) == 0)
@@ -46,7 +48,7 @@ class PluginStoreTest(SearxTestCase):
self.assertTrue(testplugin.asdf.called) # pylint: disable=E1101
-class SelfIPTest(SearxTestCase):
+class SelfIPTest(SearxTestCase): # pylint: disable=missing-class-docstring
def test_PluginStore_init(self):
plugin = plugins.load_and_initialize_plugin('searx.plugins.self_info', False, (None, {}))
store = plugins.PluginStore()
@@ -99,7 +101,7 @@ class SelfIPTest(SearxTestCase):
self.assertFalse('user-agent' in search.result_container.answers)
-class HashPluginTest(SearxTestCase):
+class HashPluginTest(SearxTestCase): # pylint: disable=missing-class-docstring
def test_PluginStore_init(self):
store = plugins.PluginStore()
plugin = plugins.load_and_initialize_plugin('searx.plugins.hash_plugin', False, (None, {}))
diff --git a/tests/unit/test_preferences.py b/tests/unit/test_preferences.py
index a33c78a44..5855c12a6 100644
--- a/tests/unit/test_preferences.py
+++ b/tests/unit/test_preferences.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring, invalid-name
+
from searx.locales import locales_initialize
from searx.preferences import (
EnumStringSetting,
@@ -12,13 +15,13 @@ from tests import SearxTestCase
locales_initialize()
-class PluginStub:
+class PluginStub: # pylint: disable=missing-class-docstring, too-few-public-methods
def __init__(self, plugin_id, default_on):
self.id = plugin_id
self.default_on = default_on
-class TestSettings(SearxTestCase):
+class TestSettings(SearxTestCase): # pylint: disable=missing-class-docstring
# map settings
def test_map_setting_invalid_default_value(self):
@@ -118,9 +121,9 @@ class TestSettings(SearxTestCase):
self.assertEqual(set(setting.get_enabled()), set(['plugin1', 'plugin3']))
-class TestPreferences(SearxTestCase):
+class TestPreferences(SearxTestCase): # pylint: disable=missing-class-docstring
def test_encode(self):
- from searx.preferences import Preferences
+ from searx.preferences import Preferences # pylint: disable=import-outside-toplevel
pref = Preferences(['simple'], ['general'], {}, [])
url_params = (
diff --git a/tests/unit/test_query.py b/tests/unit/test_query.py
index 59bbd6574..b4f5f8a0d 100644
--- a/tests/unit/test_query.py
+++ b/tests/unit/test_query.py
@@ -1,3 +1,6 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
+
from searx import settings
from searx.engines import load_engines
from searx.query import RawTextQuery
@@ -16,7 +19,7 @@ TEST_ENGINES = [
]
-class TestQuery(SearxTestCase):
+class TestQuery(SearxTestCase): # pylint:disable=missing-class-docstring
def test_simple_query(self):
query_text = 'the query'
query = RawTextQuery(query_text, [])
@@ -56,7 +59,7 @@ class TestQuery(SearxTestCase):
self.assertEqual(query.getFullQuery(), '<8 another text')
-class TestLanguageParser(SearxTestCase):
+class TestLanguageParser(SearxTestCase): # pylint:disable=missing-class-docstring
def test_language_code(self):
language = 'es-ES'
query_text = 'the query'
@@ -144,7 +147,7 @@ class TestLanguageParser(SearxTestCase):
self.assertEqual(query.autocomplete_list, [':zh-cn', ':zh-hk', ':zh-tw'])
-class TestTimeoutParser(SearxTestCase):
+class TestTimeoutParser(SearxTestCase): # pylint:disable=missing-class-docstring
def test_timeout_below100(self):
query_text = '<3 the query'
query = RawTextQuery(query_text, [])
@@ -196,7 +199,7 @@ class TestTimeoutParser(SearxTestCase):
self.assertEqual(query.autocomplete_list, ['<3', '<850'])
-class TestExternalBangParser(SearxTestCase):
+class TestExternalBangParser(SearxTestCase): # pylint:disable=missing-class-docstring
def test_external_bang(self):
query_text = '!!ddg the query'
query = RawTextQuery(query_text, [])
@@ -226,7 +229,7 @@ class TestExternalBangParser(SearxTestCase):
self.assertEqual(query.get_autocomplete_full_query(a), a + ' the query')
-class TestBang(SearxTestCase):
+class TestBang(SearxTestCase): # pylint:disable=missing-class-docstring
SPECIFIC_BANGS = ['!dummy_engine', '!du', '!general']
THE_QUERY = 'the query'
diff --git a/tests/unit/test_results.py b/tests/unit/test_results.py
index 113e9cd3c..72486bbc7 100644
--- a/tests/unit/test_results.py
+++ b/tests/unit/test_results.py
@@ -1,4 +1,5 @@
-# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
from searx.results import ResultContainer
from tests import SearxTestCase
@@ -17,8 +18,7 @@ def fake_result(url='https://aa.bb/cc?dd=ee#ff', title='aaa', content='bbb', eng
return result
-# TODO
-class ResultContainerTestCase(SearxTestCase):
+class ResultContainerTestCase(SearxTestCase): # pylint: disable=missing-class-docstring
def test_empty(self):
c = ResultContainer()
self.assertEqual(c.get_ordered_results(), [])
diff --git a/tests/unit/test_search.py b/tests/unit/test_search.py
index 87f5f280b..b85c90c68 100644
--- a/tests/unit/test_search.py
+++ b/tests/unit/test_search.py
@@ -1,4 +1,5 @@
-# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring, invalid-name
from copy import copy
@@ -23,7 +24,7 @@ TEST_ENGINES = [
]
-class SearchQueryTestCase(SearxTestCase):
+class SearchQueryTestCase(SearxTestCase): # pylint: disable=missing-class-docstring
def test_repr(self):
s = SearchQuery('test', [EngineRef('bing', 'general')], 'all', 0, 1, '1', 5.0, 'g')
self.assertEqual(
@@ -42,10 +43,10 @@ class SearchQueryTestCase(SearxTestCase):
self.assertEqual(s, t)
-class SearchTestCase(SearxTestCase):
+class SearchTestCase(SearxTestCase): # pylint: disable=missing-class-docstring
def setUp(self):
- from searx import webapp # pylint disable=import-outside-toplevel
+ from searx import webapp # pylint: disable=import-outside-toplevel
self.app = webapp.app
diff --git a/tests/unit/test_settings_loader.py b/tests/unit/test_settings_loader.py
index 2330e8460..088767597 100644
--- a/tests/unit/test_settings_loader.py
+++ b/tests/unit/test_settings_loader.py
@@ -1,4 +1,5 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
from os.path import dirname, join, abspath
from unittest.mock import patch
@@ -11,7 +12,7 @@ from tests import SearxTestCase
test_dir = abspath(dirname(__file__))
-class TestLoad(SearxTestCase):
+class TestLoad(SearxTestCase): # pylint: disable=missing-class-docstring
def test_load_zero(self):
with self.assertRaises(SearxSettingsException):
settings_loader.load_yaml('/dev/zero')
@@ -29,7 +30,7 @@ class TestLoad(SearxTestCase):
self.assertEqual(settings_loader.existing_filename_or_none(bad_settings_path), bad_settings_path)
-class TestDefaultSettings(SearxTestCase):
+class TestDefaultSettings(SearxTestCase): # pylint: disable=missing-class-docstring
def test_load(self):
settings, msg = settings_loader.load_settings(load_user_settings=False)
self.assertTrue(msg.startswith('load the default settings from'))
@@ -43,7 +44,7 @@ class TestDefaultSettings(SearxTestCase):
self.assertTrue(isinstance(settings['default_doi_resolver'], str))
-class TestUserSettings(SearxTestCase):
+class TestUserSettings(SearxTestCase): # pylint: disable=missing-class-docstring
def test_is_use_default_settings(self):
self.assertFalse(settings_loader.is_use_default_settings({}))
self.assertTrue(settings_loader.is_use_default_settings({'use_default_settings': True}))
diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py
index dcb2cb9f2..1a6fba46d 100644
--- a/tests/unit/test_utils.py
+++ b/tests/unit/test_utils.py
@@ -1,4 +1,6 @@
-# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring, invalid-name
+
import lxml.etree
from lxml import html
@@ -8,7 +10,7 @@ from searx import utils
from tests import SearxTestCase
-class TestUtils(SearxTestCase):
+class TestUtils(SearxTestCase): # pylint: disable=missing-class-docstring
def test_gen_useragent(self):
self.assertIsInstance(utils.gen_useragent(), str)
self.assertIsNotNone(utils.gen_useragent())
@@ -85,8 +87,8 @@ class TestUtils(SearxTestCase):
utils.extract_url([], 'https://example.com')
def test_html_to_text_invalid(self):
- html = '<p><b>Lorem ipsum</i>dolor sit amet</p>'
- self.assertEqual(utils.html_to_text(html), "Lorem ipsum")
+ _html = '<p><b>Lorem ipsum</i>dolor sit amet</p>'
+ self.assertEqual(utils.html_to_text(_html), "Lorem ipsum")
def test_ecma_unscape(self):
self.assertEqual(utils.ecma_unescape('text%20with%20space'), 'text with space')
@@ -94,9 +96,9 @@ class TestUtils(SearxTestCase):
self.assertEqual(utils.ecma_unescape('text using %u: %u5409, %u4E16%u754c'), 'text using %u: 吉, 世界')
-class TestHTMLTextExtractor(SearxTestCase):
+class TestHTMLTextExtractor(SearxTestCase): # pylint: disable=missing-class-docstring
def setUp(self):
- self.html_text_extractor = utils._HTMLTextExtractor()
+ self.html_text_extractor = utils._HTMLTextExtractor() # pylint: disable=protected-access
def test__init__(self):
self.assertEqual(self.html_text_extractor.result, [])
@@ -117,11 +119,11 @@ class TestHTMLTextExtractor(SearxTestCase):
def test_invalid_html(self):
text = '<p><b>Lorem ipsum</i>dolor sit amet</p>'
- with self.assertRaises(utils._HTMLTextExtractorException):
+ with self.assertRaises(utils._HTMLTextExtractorException): # pylint: disable=protected-access
self.html_text_extractor.feed(text)
-class TestXPathUtils(SearxTestCase):
+class TestXPathUtils(SearxTestCase): # pylint: disable=missing-class-docstring
TEST_DOC = """<ul>
<li>Text in <b>bold</b> and <i>italic</i> </li>
diff --git a/tests/unit/test_webadapter.py b/tests/unit/test_webadapter.py
index 2aa5cba8b..493020859 100644
--- a/tests/unit/test_webadapter.py
+++ b/tests/unit/test_webadapter.py
@@ -1,4 +1,5 @@
-# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
from searx.preferences import Preferences
from searx.engines import engines
@@ -24,19 +25,19 @@ TEST_ENGINES = [
SEARCHQUERY = [EngineRef(PRIVATE_ENGINE_NAME, 'general')]
-class ValidateQueryCase(SearxTestCase):
+class ValidateQueryCase(SearxTestCase): # pylint: disable=missing-class-docstring
@classmethod
def setUpClass(cls):
searx.search.initialize(TEST_ENGINES)
- def test_query_private_engine_without_token(self):
+ def test_query_private_engine_without_token(self): # pylint:disable=invalid-name
preferences = Preferences(['simple'], ['general'], engines, [])
valid, unknown, invalid_token = validate_engineref_list(SEARCHQUERY, preferences)
self.assertEqual(len(valid), 0)
self.assertEqual(len(unknown), 0)
self.assertEqual(len(invalid_token), 1)
- def test_query_private_engine_with_incorrect_token(self):
+ def test_query_private_engine_with_incorrect_token(self): # pylint:disable=invalid-name
preferences_with_tokens = Preferences(['simple'], ['general'], engines, [])
preferences_with_tokens.parse_dict({'tokens': 'bad-token'})
valid, unknown, invalid_token = validate_engineref_list(SEARCHQUERY, preferences_with_tokens)
@@ -44,7 +45,7 @@ class ValidateQueryCase(SearxTestCase):
self.assertEqual(len(unknown), 0)
self.assertEqual(len(invalid_token), 1)
- def test_query_private_engine_with_correct_token(self):
+ def test_query_private_engine_with_correct_token(self): # pylint:disable=invalid-name
preferences_with_tokens = Preferences(['simple'], ['general'], engines, [])
preferences_with_tokens.parse_dict({'tokens': 'my-token'})
valid, unknown, invalid_token = validate_engineref_list(SEARCHQUERY, preferences_with_tokens)
diff --git a/tests/unit/test_webapp.py b/tests/unit/test_webapp.py
index 9e8bc24ce..868645e17 100644
--- a/tests/unit/test_webapp.py
+++ b/tests/unit/test_webapp.py
@@ -1,4 +1,5 @@
-# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
import json
from urllib.parse import ParseResult
@@ -11,15 +12,15 @@ from searx.preferences import Preferences
from tests import SearxTestCase
-class ViewsTestCase(SearxTestCase):
+class ViewsTestCase(SearxTestCase): # pylint: disable=missing-class-docstring, too-many-public-methods
def setUp(self):
# skip init function (no external HTTP request)
- def dummy(*args, **kwargs):
+ def dummy(*args, **kwargs): # pylint: disable=unused-argument
pass
self.setattr4test(searx.search.processors, 'initialize_processor', dummy)
- from searx import webapp # pylint disable=import-outside-toplevel
+ from searx import webapp # pylint: disable=import-outside-toplevel
webapp.app.config['TESTING'] = True # to get better error messages
self.app = webapp.app.test_client()
@@ -60,10 +61,10 @@ class ViewsTestCase(SearxTestCase):
Timing(engine='youtube', total=0.9, load=0.6),
]
- def search_mock(search_self, *args):
+ def search_mock(search_self, *args): # pylint: disable=unused-argument
search_self.result_container = Mock(
get_ordered_results=lambda: test_results,
- answers=dict(),
+ answers={},
corrections=set(),
suggestions=set(),
infoboxes=[],
@@ -87,7 +88,8 @@ class ViewsTestCase(SearxTestCase):
self.setattr4test(Preferences, 'get_value', preferences_get_value)
- self.maxDiff = None # to see full diffs
+ # to see full diffs
+ self.maxDiff = None # pylint: disable=invalid-name
def test_index_empty(self):
result = self.app.post('/')
diff --git a/tests/unit/test_webutils.py b/tests/unit/test_webutils.py
index b4395539b..c6c441dab 100644
--- a/tests/unit/test_webutils.py
+++ b/tests/unit/test_webutils.py
@@ -1,10 +1,12 @@
-# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: AGPL-3.0-or-later
+# pylint: disable=missing-module-docstring
+
import mock
from searx import webutils
from tests import SearxTestCase
-class TestWebUtils(SearxTestCase):
+class TestWebUtils(SearxTestCase): # pylint: disable=missing-class-docstring
def test_prettify_url(self):
data = (
('https://searx.me/', 'https://searx.me/'),
@@ -32,6 +34,7 @@ class TestWebUtils(SearxTestCase):
query = 'a test'
self.assertEqual(webutils.highlight_content(content, query), '<span class="highlight">a</span>')
+ # pylint: disable=line-too-long
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'),
@@ -67,7 +70,7 @@ class TestWebUtils(SearxTestCase):
self.assertEqual(webutils.highlight_content(content, query), expected)
-class TestUnicodeWriter(SearxTestCase):
+class TestUnicodeWriter(SearxTestCase): # pylint: disable=missing-class-docstring
def setUp(self):
self.unicode_writer = webutils.CSVWriter(mock.MagicMock())
@@ -82,7 +85,7 @@ class TestUnicodeWriter(SearxTestCase):
self.assertEqual(self.unicode_writer.writerow.call_count, len(rows))
-class TestNewHmac(SearxTestCase):
+class TestNewHmac(SearxTestCase): # pylint: disable=missing-class-docstring
def test_bytes(self):
data = b'http://example.com'
with self.assertRaises(AttributeError):