add redirect method to app

This commit is contained in:
Tim Hoagland 2022-05-02 12:44:15 -04:00 committed by David Lord
parent bd56d19b16
commit fdab801fbb
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
5 changed files with 55 additions and 1 deletions

View file

@ -158,6 +158,22 @@ class TestUrlFor:
assert flask.url_for("myview", _method="POST") == "/myview/create"
def test_redirect_no_app():
response = flask.redirect("https://localhost", 307)
assert response.location == "https://localhost"
assert response.status_code == 307
def test_redirect_with_app(app):
def redirect(location, code=302):
raise ValueError
app.redirect = redirect
with app.app_context(), pytest.raises(ValueError):
flask.redirect("other")
class TestNoImports:
"""Test Flasks are created without import.