Skip to content
Myr

test_regression.py

This file

Path

tests/test_regression.py

30 lines · 712 bytes · Python

Last changed by

Not known.

History of this file

Take it

1import flask234def test_aborting(app):5    class Foo(Exception):6        whatever = 4278    @app.errorhandler(Foo)9    def handle_foo(e):10        return str(e.whatever)1112    @app.route("/")13    def index():14        raise flask.abort(flask.redirect(flask.url_for("test")))1516    @app.route("/test")17    def test():18        raise Foo()1920    with app.test_client() as c:21        rv = c.get("/")22        location_parts = rv.headers["Location"].rpartition("/")2324        if location_parts[0]:25            # For older Werkzeug that used absolute redirects.26            assert location_parts[0] == "http://localhost"2728        assert location_parts[2] == "test"29        rv = c.get("/test")30        assert rv.data == b"42"