Home / Function/ test_template_test() — flask Function Reference

test_template_test() — flask Function Reference

Architecture documentation for the test_template_test() function in test_blueprints.py from the flask codebase.

Entity Profile

Dependency Diagram

graph TD
  9e8d2365_4d41_6c4c_82bf_fe4927dbf979["test_template_test()"]
  4366a441_d387_52f9_ec8d_1c41c71c00a8["test_blueprints.py"]
  9e8d2365_4d41_6c4c_82bf_fe4927dbf979 -->|defined in| 4366a441_d387_52f9_ec8d_1c41c71c00a8
  style 9e8d2365_4d41_6c4c_82bf_fe4927dbf979 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_blueprints.py lines 522–556

def test_template_test(app):
    bp = flask.Blueprint("bp", __name__)

    @bp.app_template_test()
    def is_boolean(value):
        return isinstance(value, bool)

    @bp.app_template_test
    def boolean_2(value):
        return isinstance(value, bool)

    @bp.app_template_test("my_boolean_custom_name")
    def boolean_3(value):
        return isinstance(value, bool)

    @bp.app_template_test(name="my_boolean_custom_name_2")
    def boolean_4(value):
        return isinstance(value, bool)

    app.register_blueprint(bp, url_prefix="/py")
    assert "is_boolean" in app.jinja_env.tests.keys()
    assert app.jinja_env.tests["is_boolean"] == is_boolean
    assert app.jinja_env.tests["is_boolean"](False)

    assert "boolean_2" in app.jinja_env.tests.keys()
    assert app.jinja_env.tests["boolean_2"] == boolean_2
    assert app.jinja_env.tests["boolean_2"](False)

    assert "my_boolean_custom_name" in app.jinja_env.tests.keys()
    assert app.jinja_env.tests["my_boolean_custom_name"] == boolean_3
    assert app.jinja_env.tests["my_boolean_custom_name"](False)

    assert "my_boolean_custom_name_2" in app.jinja_env.tests.keys()
    assert app.jinja_env.tests["my_boolean_custom_name_2"] == boolean_4
    assert app.jinja_env.tests["my_boolean_custom_name_2"](False)

Subdomains

Frequently Asked Questions

What does test_template_test() do?
test_template_test() is a function in the flask codebase, defined in tests/test_blueprints.py.
Where is test_template_test() defined?
test_template_test() is defined in tests/test_blueprints.py at line 522.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free