From 24289e97af233f11d9c145f80604b2ee416254a1 Mon Sep 17 00:00:00 2001 From: Dave Barker Date: Wed, 15 Jun 2016 02:15:33 +0100 Subject: [PATCH] Add test for new template auto reload debug behaviour --- tests/test_templating.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_templating.py b/tests/test_templating.py index b60a592a..e65fe834 100644 --- a/tests/test_templating.py +++ b/tests/test_templating.py @@ -14,6 +14,7 @@ import pytest import flask import logging from jinja2 import TemplateNotFound +import werkzeug.serving def test_context_processing(): @@ -346,6 +347,22 @@ def test_templates_auto_reload(): app.config['TEMPLATES_AUTO_RELOAD'] = True assert app.jinja_env.auto_reload is True +def test_templates_auto_reload_debug_run(monkeypatch): + # debug is None in config, config option is None, app.run(debug=True) + rv = {} + + # Mocks werkzeug.serving.run_simple method + def run_simple_mock(*args, **kwargs): + rv['passthrough_errors'] = kwargs.get('passthrough_errors') + + app = flask.Flask(__name__) + monkeypatch.setattr(werkzeug.serving, 'run_simple', run_simple_mock) + + assert app.config['TEMPLATES_AUTO_RELOAD'] is None + assert app.jinja_env.auto_reload is False + app.run(debug=True) + assert app.jinja_env.auto_reload is True + def test_template_loader_debugging(test_apps): from blueprintapp import app