diff options
author | Alexandre Flament <alex@al-f.net> | 2020-11-17 10:39:44 +0100 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2020-11-17 10:39:44 +0100 |
commit | 230a5ecd04efd48363588f89a7facd6fc0ed89e9 (patch) | |
tree | bbd490120caf1c70d205a7149172250c1e977b48 /tests | |
parent | 17b48ff6e858b0c74116068cf6444bd578bbb747 (diff) | |
download | searxng-230a5ecd04efd48363588f89a7facd6fc0ed89e9.tar.gz searxng-230a5ecd04efd48363588f89a7facd6fc0ed89e9.zip |
[fix] fix a test_standalone_searx test case
If test_engines_init.py runs before test_standalone_searx.py, the engine list is not empty.
It makes test_get_search_query flaky.
This commit initializes the engline list in test_standalone_searx.py
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/test_standalone_searx.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/unit/test_standalone_searx.py b/tests/unit/test_standalone_searx.py index ddf140799..40d43e4e7 100644 --- a/tests/unit/test_standalone_searx.py +++ b/tests/unit/test_standalone_searx.py @@ -8,7 +8,8 @@ import sys from mock import Mock, patch from nose2.tools import params -from searx.search import SearchQuery +from searx.search import SearchQuery, EngineRef +from searx.engines import initialize_engines from searx.testing import SearxTestCase @@ -25,6 +26,13 @@ def get_standalone_searx_module(): class StandaloneSearx(SearxTestCase): """Unit test for standalone_searx.""" + @classmethod + def setUpClass(cls): + engine_list = [{'engine': 'dummy', 'name': 'engine1', 'shortcut': 'e1'}, + {'engine': 'dummy', 'name': 'engine2', 'shortcut': 'e2'}] + + initialize_engines(engine_list) + def test_parse_argument_no_args(self): """Test parse argument without args.""" sas = get_standalone_searx_module() @@ -95,7 +103,9 @@ class StandaloneSearx(SearxTestCase): args = sas.parse_argument(['rain', ]) search_q = sas.get_search_query(args) self.assertTrue(search_q) - self.assertEqual(search_q, SearchQuery('rain', [], ['general'], 'all', 0, 1, None, None, None)) + self.assertEqual(search_q, SearchQuery('rain', [EngineRef('engine1', 'general', False), + EngineRef('engine2', 'general', False)], + ['general'], 'all', 0, 1, None, None, None)) def test_no_parsed_url(self): """test no_parsed_url func""" |