def test_route_decorator_custom_endpoint_with_dots():
    bp = flask.Blueprint('bp', __name__)

    @bp.route('/foo')
    def foo():
        return flask.request.endpoint

    try:
        @bp.route('/bar', endpoint='bar.bar')
        def foo_bar():
            return flask.request.endpoint
    except AssertionError:
        pass
    else:
        raise AssertionError('expected AssertionError not raised')

    try:
        @bp.route('/bar/123', endpoint='bar.123')
        def foo_bar_foo():
            return flask.request.endpoint
    except __HOLE__:
        pass
    else:
        raise AssertionError('expected AssertionError not raised')

    def foo_foo_foo():
        pass

    pytest.raises(
        AssertionError,
        lambda: bp.add_url_rule(
            '/bar/123', endpoint='bar.123', view_func=foo_foo_foo
        )
    )

    pytest.raises(
        AssertionError,
        bp.route('/bar/123', endpoint='bar.123'),
        lambda: None
    )

    app = flask.Flask(__name__)
    app.register_blueprint(bp, url_prefix='/py')

    c = app.test_client()
    assert c.get('/py/foo').data == b'bp.foo'
    # The rule's didn't actually made it through
    rv = c.get('/py/bar')
    assert rv.status_code == 404
    rv = c.get('/py/bar/123')
    assert rv.status_code == 404
dataset/ETHPy150Open pallets/flask/tests/test_blueprints.py/test_route_decorator_custom_endpoint_with_dots