@@ -1,7 +1,6 @@
11# -*- coding: utf-8 -*-
22"""Test utils/standalone_searx.py"""
33import datetime
4−import importlib.util
54import io
65import sys
76
@@ -10,16 +9,7 @@ from nose2.tools import params
109
1110from searx.search import SearchQuery, EngineRef, initialize
1211from searx.testing import SearxTestCase
13−
14−
15−def get_standalone_searx_module():
16− """Get standalone_searx module."""
17− module_name = 'utils.standalone_searx'
18− filename = 'utils/standalone_searx.py'
19− spec = importlib.util.spec_from_file_location(module_name, filename)
20− sas = importlib.util.module_from_spec(spec)
21− spec.loader.exec_module(sas)
22− return sas
12+from searx_extra import standalone_searx as sas
2313
2414
2515class StandaloneSearx(SearxTestCase):
@@ -33,7 +23,6 @@ class StandaloneSearx(SearxTestCase):
3323
3424 def test_parse_argument_no_args(self):
3525 """Test parse argument without args."""
36− sas = get_standalone_searx_module()
3726 with patch.object(sys, 'argv', ['standalone_searx']), \
3827 self.assertRaises(SystemExit):
3928 sys.stderr = io.StringIO()
@@ -42,7 +31,6 @@ class StandaloneSearx(SearxTestCase):
4231
4332 def test_parse_argument_basic_args(self):
4433 """Test parse argument with basic args."""
45− sas = get_standalone_searx_module()
4634 query = 'red box'
4735 exp_dict = {
4836 'query': query, 'category': 'general', 'lang': 'all', 'pageno': 1,
@@ -56,7 +44,6 @@ class StandaloneSearx(SearxTestCase):
5644
5745 def test_to_dict(self):
5846 """test to_dict."""
59− sas = get_standalone_searx_module()
6047 self.assertEqual(
6148 sas.to_dict(
6249 sas.get_search_query(sas.parse_argument(['red box']))),
@@ -72,7 +59,6 @@ class StandaloneSearx(SearxTestCase):
7259
7360 def test_to_dict_with_mock(self):
7461 """test to dict."""
75− sas = get_standalone_searx_module()
7662 with patch.object(sas.searx.search, 'Search') as mock_s:
7763 m_search = mock_s().search()
7864 m_sq = Mock()
@@ -97,7 +83,6 @@ class StandaloneSearx(SearxTestCase):
9783
9884 def test_get_search_query(self):
9985 """test get_search_query."""
100− sas = get_standalone_searx_module()
10186 args = sas.parse_argument(['rain', ])
10287 search_q = sas.get_search_query(args)
10388 self.assertTrue(search_q)
@@ -106,7 +91,6 @@ class StandaloneSearx(SearxTestCase):
10691
10792 def test_no_parsed_url(self):
10893 """test no_parsed_url func"""
109− sas = get_standalone_searx_module()
11094 self.assertEqual(
11195 sas.no_parsed_url([{'parsed_url': 'http://example.com'}]),
11296 [{}]
@@ -119,11 +103,9 @@ class StandaloneSearx(SearxTestCase):
119103 )
120104 def test_json_serial(self, arg, exp_res):
121105 """test json_serial func"""
122− sas = get_standalone_searx_module()
123106 self.assertEqual(sas.json_serial(arg), exp_res)
124107
125108 def test_json_serial_error(self):
126109 """test error on json_serial."""
127− sas = get_standalone_searx_module()
128110 with self.assertRaises(TypeError):
129111 sas.json_serial('a')