allow explicit instance_path in create_app()

this will be necessary to point pytest's app fixture at a different
instance directory with test data
This commit is contained in:
Brian S. Stephan 2020-03-07 09:24:20 -06:00
parent d9c4cbdfe1
commit 17bbe9c6b4
1 changed files with 4 additions and 2 deletions

View File

@ -11,8 +11,8 @@ __version__ = get_versions()['version']
del get_versions
def create_app(test_config=None):
app = Flask(__name__, instance_relative_config=True)
def create_app(instance_path=None, test_config=None):
app = Flask(__name__, instance_relative_config=True, instance_path=instance_path)
# if it doesn't already exist, create the instance folder
os.makedirs(app.instance_path, exist_ok=True)
@ -29,6 +29,8 @@ def create_app(test_config=None):
logger = logging.getLogger(__name__)
logger.debug("instance path: %s", app.instance_path)
@app.before_request
def log_request():
logger.info("REQUEST: [ %s ]", request.path)