forked from Icycoide/searxng
[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 <markus.heiser@darmarit.de>
This commit is contained in:
parent
6948689d2a
commit
bb04699b17
5 changed files with 35 additions and 45 deletions
|
@ -2,7 +2,7 @@
|
|||
# pylint: disable=missing-module-docstring
|
||||
|
||||
from parameterized.parameterized import parameterized
|
||||
from searx.engines import load_engines
|
||||
import searx.search
|
||||
from searx.query import RawTextQuery
|
||||
from tests import SearxTestCase
|
||||
|
||||
|
@ -218,10 +218,10 @@ class TestBang(SearxTestCase): # pylint:disable=missing-class-docstring
|
|||
THE_QUERY = 'the query'
|
||||
|
||||
def setUp(self):
|
||||
load_engines(TEST_ENGINES)
|
||||
searx.search.initialize(TEST_ENGINES)
|
||||
|
||||
def tearDown(self):
|
||||
load_engines([])
|
||||
searx.search.load_engines([])
|
||||
|
||||
@parameterized.expand(SPECIFIC_BANGS)
|
||||
def test_bang(self, bang: str):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue