Fix nested blueprint url_prefix

This fixes the case where the blueprint is registered with a
url_prefix but any child blueprints have no prefixes.
This commit is contained in:
pgjones 2021-05-16 19:32:29 +01:00
parent f64fff6476
commit 6fbdeb80c7
2 changed files with 16 additions and 0 deletions

View file

@ -868,3 +868,17 @@ def test_nested_blueprint_url_prefix(app, client):
assert client.get("/parent/child/").data == b"Child"
assert client.get("/parent/child/grandchild/").data == b"Grandchild"
assert client.get("/parent/child/orange/").data == b"Apple"
def test_nested_blueprint_url_prefix_only_parent_prefix(app, client):
parent = flask.Blueprint("parent", __name__)
child = flask.Blueprint("child", __name__)
@child.route("/child-endpoint")
def child_index():
return "Child"
parent.register_blueprint(child)
app.register_blueprint(parent, url_prefix="/parent")
assert client.get("/parent/child-endpoint").data == b"Child"