finish moving url_for to app

move entire implementation to app
make special build args actual keyword-only args
handle no app context in method
mention other config in server_name error
implicit external with scheme
use adapter.build url_scheme argument
rewrite documentation
This commit is contained in:
David Lord 2022-05-14 12:43:38 -07:00
parent 92acd05d9b
commit 39f9363296
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
3 changed files with 185 additions and 152 deletions

View file

@ -119,11 +119,15 @@ class TestUrlFor:
)
def test_url_for_with_scheme_not_external(self, app, req_ctx):
@app.route("/")
def index():
return "42"
app.add_url_rule("/", endpoint="index")
pytest.raises(ValueError, flask.url_for, "index", _scheme="https")
# Implicit external with scheme.
url = flask.url_for("index", _scheme="https")
assert url == "https://localhost/"
# Error when external=False with scheme
with pytest.raises(ValueError):
flask.url_for("index", _scheme="https", _external=False)
def test_url_for_with_alternating_schemes(self, app, req_ctx):
@app.route("/")