Home / Function/ test_nested_blueprint() — flask Function Reference

test_nested_blueprint() — flask Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

tests/test_blueprints.py lines 874–920

def test_nested_blueprint(app, client):
    parent = flask.Blueprint("parent", __name__)
    child = flask.Blueprint("child", __name__)
    grandchild = flask.Blueprint("grandchild", __name__)

    @parent.errorhandler(403)
    def forbidden(e):
        return "Parent no", 403

    @parent.route("/")
    def parent_index():
        return "Parent yes"

    @parent.route("/no")
    def parent_no():
        flask.abort(403)

    @child.route("/")
    def child_index():
        return "Child yes"

    @child.route("/no")
    def child_no():
        flask.abort(403)

    @grandchild.errorhandler(403)
    def grandchild_forbidden(e):
        return "Grandchild no", 403

    @grandchild.route("/")
    def grandchild_index():
        return "Grandchild yes"

    @grandchild.route("/no")
    def grandchild_no():
        flask.abort(403)

    child.register_blueprint(grandchild, url_prefix="/grandchild")
    parent.register_blueprint(child, url_prefix="/child")
    app.register_blueprint(parent, url_prefix="/parent")

    assert client.get("/parent/").data == b"Parent yes"
    assert client.get("/parent/child/").data == b"Child yes"
    assert client.get("/parent/child/grandchild/").data == b"Grandchild yes"
    assert client.get("/parent/no").data == b"Parent no"
    assert client.get("/parent/child/no").data == b"Parent no"
    assert client.get("/parent/child/grandchild/no").data == b"Grandchild no"

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free