Browse Source

[fix] unit test: don't load /etc/searx/settings.yml

Add a new environment variable SEARX_DISABLE_ETC_SETTINGS
to disable loading of /etc/searx/settings.yml

unit tests:
* set SEARX_DISABLE_ETC_SETTINGS to 1
* remove SEARX_SETTINGS_PATH if it exists
Alexandre Flament 4 years ago
parent
commit
d1cffc55cb
2 changed files with 6 additions and 0 deletions
  1. 3 0
      searx/settings_loader.py
  2. 3 0
      tests/__init__.py

+ 3 - 0
searx/settings_loader.py

@@ -40,6 +40,9 @@ def get_user_settings_path():
         # enviroment variable SEARX_SETTINGS_PATH
         return check_settings_yml(environ['SEARX_SETTINGS_PATH'])
 
+    if environ.get('SEARX_DISABLE_ETC_SETTINGS', '').lower() in ('1', 'true'):
+        return None
+
     # if not, get it from searx code base or last solution from /etc/searx
     return check_settings_yml('/etc/searx/settings.yml')
 

+ 3 - 0
tests/__init__.py

@@ -1,2 +1,5 @@
 import os
+
 os.environ['SEARX_DEBUG'] = '1'
+os.environ['SEARX_DISABLE_ETC_SETTINGS'] = '1'
+os.environ.pop('SEARX_SETTINGS_PATH', None)