mirror of
https://github.com/YunoHost-Apps/ihatemoney_ynh.git
synced 2024-09-03 19:26:15 +02:00
Do not load user-overriden settings in unit tests.
Loading not versioned settings.py during tests make them less predictable. That's inspired from django behaviour with DJANGO_SETTING_MODULE environment variable.
This commit is contained in:
parent
a8841f9d3f
commit
b685fa74d6
4 changed files with 16 additions and 7 deletions
|
@ -4,9 +4,3 @@ SQLACHEMY_ECHO = DEBUG
|
||||||
SECRET_KEY = "tralala"
|
SECRET_KEY = "tralala"
|
||||||
|
|
||||||
MAIL_DEFAULT_SENDER = ("Budget manager", "budget@notmyidea.org")
|
MAIL_DEFAULT_SENDER = ("Budget manager", "budget@notmyidea.org")
|
||||||
APPLICATION_ROOT = '/'
|
|
||||||
|
|
||||||
try:
|
|
||||||
from settings import *
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
10
budget/merged_settings.py
Normal file
10
budget/merged_settings.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
"""
|
||||||
|
Merges default settings with user-defined settings
|
||||||
|
"""
|
||||||
|
|
||||||
|
from default_settings import *
|
||||||
|
|
||||||
|
try:
|
||||||
|
from settings import *
|
||||||
|
except ImportError:
|
||||||
|
pass
|
|
@ -1,3 +1,4 @@
|
||||||
|
import os
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
from flask import Flask, g, request, session
|
from flask import Flask, g, request, session
|
||||||
|
@ -14,7 +15,8 @@ app = Flask(__name__)
|
||||||
def configure():
|
def configure():
|
||||||
""" A way to (re)configure the app, specially reset the settings
|
""" A way to (re)configure the app, specially reset the settings
|
||||||
"""
|
"""
|
||||||
app.config.from_object("default_settings")
|
config_obj = os.environ.get('FLASK_SETTINGS_MODULE', 'merged_settings')
|
||||||
|
app.config.from_object(config_obj)
|
||||||
app.wsgi_app = PrefixedWSGI(app)
|
app.wsgi_app = PrefixedWSGI(app)
|
||||||
|
|
||||||
# Deprecations
|
# Deprecations
|
||||||
|
|
|
@ -5,9 +5,12 @@ except ImportError:
|
||||||
import unittest # NOQA
|
import unittest # NOQA
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
|
import os
|
||||||
import json
|
import json
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
|
os.environ['FLASK_SETTINGS_MODULE'] = 'default_settings'
|
||||||
|
|
||||||
from flask import session
|
from flask import session
|
||||||
|
|
||||||
import run
|
import run
|
||||||
|
|
Loading…
Reference in a new issue