Home / Function/ test_teardown_request_handler_error() — flask Function Reference

test_teardown_request_handler_error() — flask Function Reference

Architecture documentation for the test_teardown_request_handler_error() function in test_basic.py from the flask codebase.

Entity Profile

Dependency Diagram

graph TD
  ed6819c9_a2d2_332b_7dd5_27cf1bc98064["test_teardown_request_handler_error()"]
  85bc4fb5_d1d7_a135_020d_69e052c12c0f["test_basic.py"]
  ed6819c9_a2d2_332b_7dd5_27cf1bc98064 -->|defined in| 85bc4fb5_d1d7_a135_020d_69e052c12c0f
  style ed6819c9_a2d2_332b_7dd5_27cf1bc98064 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_basic.py lines 791–826

def test_teardown_request_handler_error(app, client):
    called = []
    app.testing = False

    @app.teardown_request
    def teardown_request1(exc):
        assert type(exc) is ZeroDivisionError
        called.append(True)
        # This raises a new error and blows away sys.exc_info(), so we can
        # test that all teardown_requests get passed the same original
        # exception.
        try:
            raise TypeError()
        except Exception:
            pass

    @app.teardown_request
    def teardown_request2(exc):
        assert type(exc) is ZeroDivisionError
        called.append(True)
        # This raises a new error and blows away sys.exc_info(), so we can
        # test that all teardown_requests get passed the same original
        # exception.
        try:
            raise TypeError()
        except Exception:
            pass

    @app.route("/")
    def fails():
        raise ZeroDivisionError

    rv = client.get("/")
    assert rv.status_code == 500
    assert b"Internal Server Error" in rv.data
    assert len(called) == 2

Subdomains

Defined In

Frequently Asked Questions

What does test_teardown_request_handler_error() do?
test_teardown_request_handler_error() is a function in the flask codebase, defined in tests/test_basic.py.
Where is test_teardown_request_handler_error() defined?
test_teardown_request_handler_error() is defined in tests/test_basic.py at line 791.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free