merge slashes between blueprint prefix and rule

This commit is contained in:
David Lord 2018-04-27 12:27:31 -07:00
parent 34e2b4ab46
commit fa03e9e0e4
2 changed files with 15 additions and 12 deletions

View file

@ -115,17 +115,22 @@ def test_blueprint_app_error_handling(app, client):
assert client.get('/nope').data == b'you shall not pass'
def test_blueprint_prefix_slash(app, client):
bp = flask.Blueprint('test', __name__, url_prefix='/bar/')
@pytest.mark.parametrize(('prefix', 'rule', 'url'), (
('/foo/', '/bar', '/foo/bar'),
('/foo/', 'bar', '/foo/bar'),
('/foo', '/bar', '/foo/bar'),
('/foo/', '//bar', '/foo/bar'),
('/foo//', '/bar', '/foo/bar'),
))
def test_blueprint_prefix_slash(app, client, prefix, rule, url):
bp = flask.Blueprint('test', __name__, url_prefix=prefix)
@bp.route('/foo')
def foo():
@bp.route(rule)
def index():
return '', 204
app.register_blueprint(bp)
app.register_blueprint(bp, url_prefix='/spam/')
assert client.get('/bar/foo').status_code == 204
assert client.get('/spam/foo').status_code == 204
assert client.get(url).status_code == 204
def test_blueprint_url_defaults(app, client):