summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2024-08-21 08:19:54 +0200
committerMarkus Heiser <markus.heiser@darmarIT.de>2024-08-21 08:28:13 +0200
commit5be55e3309761842e070f48580a519499cfc8ceb (patch)
treec799ea226abf82bc89011fb3ab4fca91860fd648
parent5c6b126d7f2bbd12c6944247068b49ec3a9b7dee (diff)
downloadsearxng-5be55e3309761842e070f48580a519499cfc8ceb.tar.gz
searxng-5be55e3309761842e070f48580a519499cfc8ceb.zip
[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>
-rw-r--r--tests/unit/test_engines_init.py1
-rw-r--r--tests/unit/test_search.py6
-rw-r--r--tests/unit/test_webapp.py6
3 files changed, 13 insertions, 0 deletions
diff --git a/tests/unit/test_engines_init.py b/tests/unit/test_engines_init.py
index 4872a1b1b..e2445160a 100644
--- a/tests/unit/test_engines_init.py
+++ b/tests/unit/test_engines_init.py
@@ -10,6 +10,7 @@ class TestEnginesInit(SearxTestCase): # pylint: disable=missing-class-docstring
def tearDownClass(cls):
settings['outgoing']['using_tor_proxy'] = False
settings['outgoing']['extra_proxy_timeout'] = 0
+ engines.load_engines([])
def test_initialize_engines_default(self):
engine_list = [
diff --git a/tests/unit/test_search.py b/tests/unit/test_search.py
index b85c90c68..a60089aef 100644
--- a/tests/unit/test_search.py
+++ b/tests/unit/test_search.py
@@ -2,6 +2,7 @@
# pylint: disable=missing-module-docstring, invalid-name
from copy import copy
+import logging
import searx.search
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
def setUp(self):
+ log = logging.getLogger("searx")
+ log_lev = log.level
+ log.setLevel(logging.ERROR)
from searx import webapp # pylint: disable=import-outside-toplevel
+ log.setLevel(log_lev)
+
self.app = webapp.app
@classmethod
diff --git a/tests/unit/test_webapp.py b/tests/unit/test_webapp.py
index 868645e17..7c6e1ef82 100644
--- a/tests/unit/test_webapp.py
+++ b/tests/unit/test_webapp.py
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
# pylint: disable=missing-module-docstring
+import logging
import json
from urllib.parse import ParseResult
from mock import Mock
@@ -20,8 +21,13 @@ class ViewsTestCase(SearxTestCase): # pylint: disable=missing-class-docstring,
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
+ log.setLevel(log_lev)
+
webapp.app.config['TESTING'] = True # to get better error messages
self.app = webapp.app.test_client()