(app)
| 2 | |
| 3 | |
| 4 | def test_aborting(app): |
| 5 | class Foo(Exception): |
| 6 | whatever = 42 |
| 7 | |
| 8 | @app.errorhandler(Foo) |
| 9 | def handle_foo(e): |
| 10 | return str(e.whatever) |
| 11 | |
| 12 | @app.route("/") |
| 13 | def index(): |
| 14 | raise flask.abort(flask.redirect(flask.url_for("test"))) |
| 15 | |
| 16 | @app.route("/test") |
| 17 | def test(): |
| 18 | raise Foo() |
| 19 | |
| 20 | with app.test_client() as c: |
| 21 | rv = c.get("/") |
| 22 | location_parts = rv.headers["Location"].rpartition("/") |
| 23 | |
| 24 | if location_parts[0]: |
| 25 | # For older Werkzeug that used absolute redirects. |
| 26 | assert location_parts[0] == "http://localhost" |
| 27 | |
| 28 | assert location_parts[2] == "test" |
| 29 | rv = c.get("/test") |
| 30 | assert rv.data == b"42" |
nothing calls this directly
no test coverage detected