Skip to content
Myr

Merge pull request #2299 from dawran6/test-bp-template_global

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Add coverage for Blueprint.add_app_template_global

authored by David Lord · committed by GitHub · parents 99208f1, 7ce01ab · Browse files · 1 file+19 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+19 added−0 removed

  • tests:+19 added−0 removed

1 file+19 added−0 removed

modified:tests/test_blueprints.py+19 added
658 unmodified lines
659 assert b'42' not in app_page_bytes660661 assert b'42' in answer_page_bytes662 assert b'43' in answer_page_bytes663664def test_template_global():665 app = flask.Flask(__name__)666 bp = flask.Blueprint('bp', __name__)667 @bp.app_template_global()668 def get_answer():669 return 42670 # Make sure the function is not in the jinja_env already671 assert 'get_answer' not in app.jinja_env.globals.keys()672 app.register_blueprint(bp)673674 # Tests675 assert 'get_answer' in app.jinja_env.globals.keys()676 assert app.jinja_env.globals['get_answer'] is get_answer677 assert app.jinja_env.globals['get_answer']() == 42678679 with app.app_context():680 rv = flask.render_template_string('{{ get_answer() }}')681 assert rv == '42'