MCPcopy Create free account
hub / github.com/pallets/flask / test_aborting

Function test_aborting

tests/test_regression.py:4–30  ·  view source on GitHub ↗
(app)

Source from the content-addressed store, hash-verified

2
3
4def 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"

Callers

nothing calls this directly

Calls 2

test_clientMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected