1
0
mirror of https://github.com/searxng/searxng.git synced 2024-11-15 01:00:12 +01:00

[fix] unit tests: fix load / unload engines & fix messages

- https://github.com/searxng/searxng/pull/3746#issuecomment-2300965005
- https://github.com/searxng/searxng/issues/2988#issuecomment-2226929084

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser 2024-08-21 08:19:54 +02:00 committed by Markus Heiser
parent 5c6b126d7f
commit 5be55e3309
3 changed files with 13 additions and 0 deletions

View File

@ -10,6 +10,7 @@ class TestEnginesInit(SearxTestCase): # pylint: disable=missing-class-docstring
def tearDownClass(cls): def tearDownClass(cls):
settings['outgoing']['using_tor_proxy'] = False settings['outgoing']['using_tor_proxy'] = False
settings['outgoing']['extra_proxy_timeout'] = 0 settings['outgoing']['extra_proxy_timeout'] = 0
engines.load_engines([])
def test_initialize_engines_default(self): def test_initialize_engines_default(self):
engine_list = [ engine_list = [

View File

@ -2,6 +2,7 @@
# pylint: disable=missing-module-docstring, invalid-name # pylint: disable=missing-module-docstring, invalid-name
from copy import copy from copy import copy
import logging
import searx.search import searx.search
from searx.search import SearchQuery, EngineRef from searx.search import SearchQuery, EngineRef
@ -46,8 +47,13 @@ class SearchQueryTestCase(SearxTestCase): # pylint: disable=missing-class-docst
class SearchTestCase(SearxTestCase): # pylint: disable=missing-class-docstring class SearchTestCase(SearxTestCase): # pylint: disable=missing-class-docstring
def setUp(self): def setUp(self):
log = logging.getLogger("searx")
log_lev = log.level
log.setLevel(logging.ERROR)
from searx import webapp # pylint: disable=import-outside-toplevel from searx import webapp # pylint: disable=import-outside-toplevel
log.setLevel(log_lev)
self.app = webapp.app self.app = webapp.app
@classmethod @classmethod

View File

@ -1,6 +1,7 @@
# SPDX-License-Identifier: AGPL-3.0-or-later # SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring # pylint: disable=missing-module-docstring
import logging
import json import json
from urllib.parse import ParseResult from urllib.parse import ParseResult
from mock import Mock from mock import Mock
@ -20,8 +21,13 @@ class ViewsTestCase(SearxTestCase): # pylint: disable=missing-class-docstring,
self.setattr4test(searx.search.processors, 'initialize_processor', dummy) self.setattr4test(searx.search.processors, 'initialize_processor', dummy)
log = logging.getLogger("searx")
log_lev = log.level
log.setLevel(logging.ERROR)
from searx import webapp # pylint: disable=import-outside-toplevel from searx import webapp # pylint: disable=import-outside-toplevel
log.setLevel(log_lev)
webapp.app.config['TESTING'] = True # to get better error messages webapp.app.config['TESTING'] = True # to get better error messages
self.app = webapp.app.test_client() self.app = webapp.app.test_client()