From bb04699b17e014089e6dd6d0af2f01b9717ad58c Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 30 Oct 2024 13:16:31 +0100 Subject: [fix] unit tests: call searx.search.initialize in test's setUp Depending on the order the unit tests are executed, the searx.search module is initalized or not, issue reported in [1]:: Traceback (most recent call last): File "searxng/tests/unit/test_results.py", line 72, in test_result_merge_by_title self.container.extend('stract', [fake_result(engine='stract', title='short title')]) File "searxng/searx/results.py", line 243, in extend histogram_observe(standard_result_count, 'engine', engine_name, 'result', 'count') File "searxng/searx/metrics/__init__.py", line 49, in histogram_observe histogram_storage.get(*args).observe(duration) ^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'get' To ensure that the searx.search module is initialized, the - searx.engines.load_engines is replace by - searx.search.initialize [1] https://github.com/searxng/searxng/pull/3932#discussion_r1822406569 Signed-off-by: Markus Heiser --- tests/unit/test_engine_mariadb_server.py | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'tests/unit/test_engine_mariadb_server.py') diff --git a/tests/unit/test_engine_mariadb_server.py b/tests/unit/test_engine_mariadb_server.py index 423132e34..c4144a601 100644 --- a/tests/unit/test_engine_mariadb_server.py +++ b/tests/unit/test_engine_mariadb_server.py @@ -2,26 +2,11 @@ # pylint: disable=missing-module-docstring from unittest.mock import MagicMock, Mock -from searx.engines import load_engines, mariadb_server +from searx.engines import mariadb_server from tests import SearxTestCase class MariadbServerTests(SearxTestCase): # pylint: disable=missing-class-docstring - def setUp(self): - load_engines( - [ - { - 'name': 'mariadb server', - 'engine': 'mariadb_server', - 'shortcut': 'mdb', - 'timeout': 9.0, - 'disabled': True, - } - ] - ) - - def tearDown(self): - load_engines([]) def test_init_no_query_str_raises(self): self.assertRaises(ValueError, lambda: mariadb_server.init({})) -- cgit v1.2.3