Browse Source

Enhance code coverage for Blueprint.endpoint

Add basic test for the endpoint decorator for the Blueprint object.
pull/1886/head
Randy Liou 9 years ago
parent
commit
954b7ef7bb
  1. 19
      tests/test_blueprints.py

19
tests/test_blueprints.py

@ -355,6 +355,25 @@ def test_route_decorator_custom_endpoint_with_dots():
rv = c.get('/py/bar/123')
assert rv.status_code == 404
def test_endpoint_decorator():
from werkzeug.routing import Rule
app = flask.Flask(__name__)
app.url_map.add(Rule('/foo', endpoint='bar'))
bp = flask.Blueprint('bp', __name__)
@bp.endpoint('bar')
def foobar():
return flask.request.endpoint
app.register_blueprint(bp, url_prefix='/bp_prefix')
c = app.test_client()
assert c.get('/foo').data == b'bar'
assert c.get('/bp_prefix/bar').status_code == 404
def test_template_filter():
bp = flask.Blueprint('bp', __name__)
@bp.app_template_filter()

Loading…
Cancel
Save