mirror of https://github.com/searxng/searxng.git
[enh] test: load each engine to check for syntax errors
This commit is contained in:
parent
ec5adad851
commit
4fb3ed2c63
|
@ -72,11 +72,8 @@ def load_engine(engine_data):
|
||||||
|
|
||||||
engine_module = engine_data['engine']
|
engine_module = engine_data['engine']
|
||||||
|
|
||||||
try:
|
# can raise an exception
|
||||||
engine = load_module(engine_module + '.py', engine_dir)
|
engine = load_module(engine_module + '.py', engine_dir)
|
||||||
except:
|
|
||||||
logger.exception('Cannot load engine "{}"'.format(engine_module))
|
|
||||||
return None
|
|
||||||
|
|
||||||
for param_name in engine_data:
|
for param_name in engine_data:
|
||||||
if param_name == 'engine':
|
if param_name == 'engine':
|
||||||
|
@ -254,9 +251,11 @@ def load_engines(engine_list):
|
||||||
global engines
|
global engines
|
||||||
engines.clear()
|
engines.clear()
|
||||||
for engine_data in engine_list:
|
for engine_data in engine_list:
|
||||||
engine = load_engine(engine_data)
|
try:
|
||||||
if engine is not None:
|
engine = load_engine(engine_data)
|
||||||
engines[engine.name] = engine
|
engines[engine.name] = engine
|
||||||
|
except:
|
||||||
|
logger.exception('Cannot load engine "{}"'.format(engine_data['engine']))
|
||||||
return engines
|
return engines
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -136,11 +136,6 @@ app.jinja_env.lstrip_blocks = True
|
||||||
app.jinja_env.add_extension('jinja2.ext.loopcontrols')
|
app.jinja_env.add_extension('jinja2.ext.loopcontrols')
|
||||||
app.secret_key = settings['server']['secret_key']
|
app.secret_key = settings['server']['secret_key']
|
||||||
|
|
||||||
if not searx_debug \
|
|
||||||
or os.environ.get("WERKZEUG_RUN_MAIN") == "true" \
|
|
||||||
or os.environ.get('UWSGI_ORIGINAL_PROC_NAME') is not None:
|
|
||||||
initialize_engines(settings['engines'])
|
|
||||||
|
|
||||||
babel = Babel(app)
|
babel = Babel(app)
|
||||||
|
|
||||||
rtl_locales = ['ar', 'arc', 'bcc', 'bqi', 'ckb', 'dv', 'fa', 'fa_IR', 'glk', 'he',
|
rtl_locales = ['ar', 'arc', 'bcc', 'bqi', 'ckb', 'dv', 'fa', 'fa_IR', 'glk', 'he',
|
||||||
|
@ -1051,6 +1046,10 @@ def page_not_found(e):
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
if not searx_debug \
|
||||||
|
or os.environ.get("WERKZEUG_RUN_MAIN") == "true" \
|
||||||
|
or os.environ.get('UWSGI_ORIGINAL_PROC_NAME') is not None:
|
||||||
|
initialize_engines(settings['engines'])
|
||||||
logger.debug('starting webserver on %s:%s', settings['server']['bind_address'], settings['server']['port'])
|
logger.debug('starting webserver on %s:%s', settings['server']['bind_address'], settings['server']['port'])
|
||||||
app.run(
|
app.run(
|
||||||
debug=searx_debug,
|
debug=searx_debug,
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import unittest2 as unittest
|
||||||
|
from unittest2.util import strclass
|
||||||
|
from searx.engines import load_engine
|
||||||
|
from searx import settings
|
||||||
|
|
||||||
|
|
||||||
|
class TestEngine(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_engines(self):
|
||||||
|
for engine_data in settings['engines']:
|
||||||
|
load_engine(engine_data)
|
Loading…
Reference in New Issue