Bugfix allow blueprints to be registered with a different name

This allows the same blueprint to be registered multiple times at the
same level, but with differing url_prefixes and names.
This commit is contained in:
pgjones 2021-05-18 13:37:11 +01:00
parent 141fde1d8e
commit c2920e2bd9
2 changed files with 15 additions and 1 deletions

View file

@ -866,3 +866,16 @@ def test_nesting_url_prefixes(
response = client.get("/parent/child/")
assert response.status_code == 200
def test_unique_blueprint_names(app, client) -> None:
bp = flask.Blueprint("bp", __name__)
bp2 = flask.Blueprint("bp", __name__)
app.register_blueprint(bp)
app.register_blueprint(bp) # same name, same object, no error
with pytest.raises(ValueError):
app.register_blueprint(bp2) # same name, different object
app.register_blueprint(bp2, name="alt") # different name