Home / Function/ test_async_before_after_request() — flask Function Reference

test_async_before_after_request() — flask Function Reference

Architecture documentation for the test_async_before_after_request() function in test_async.py from the flask codebase.

Entity Profile

Dependency Diagram

graph TD
  cd9dfa3e_f0f5_4fa8_faab_a2b5d37b4def["test_async_before_after_request()"]
  2ca33915_61cb_9ace_26ed_1542aea53eee["test_async.py"]
  cd9dfa3e_f0f5_4fa8_faab_a2b5d37b4def -->|defined in| 2ca33915_61cb_9ace_26ed_1542aea53eee
  a6a6eebd_ef36_03b8_4a50_6132df190e13["get()"]
  cd9dfa3e_f0f5_4fa8_faab_a2b5d37b4def -->|calls| a6a6eebd_ef36_03b8_4a50_6132df190e13
  style cd9dfa3e_f0f5_4fa8_faab_a2b5d37b4def fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_async.py lines 97–145

def test_async_before_after_request():
    app_before_called = False
    app_after_called = False
    bp_before_called = False
    bp_after_called = False

    app = Flask(__name__)

    @app.route("/")
    def index():
        return ""

    @app.before_request
    async def before():
        nonlocal app_before_called
        app_before_called = True

    @app.after_request
    async def after(response):
        nonlocal app_after_called
        app_after_called = True
        return response

    blueprint = Blueprint("bp", __name__)

    @blueprint.route("/")
    def bp_index():
        return ""

    @blueprint.before_request
    async def bp_before():
        nonlocal bp_before_called
        bp_before_called = True

    @blueprint.after_request
    async def bp_after(response):
        nonlocal bp_after_called
        bp_after_called = True
        return response

    app.register_blueprint(blueprint, url_prefix="/bp")

    test_client = app.test_client()
    test_client.get("/")
    assert app_before_called
    assert app_after_called
    test_client.get("/bp/")
    assert bp_before_called
    assert bp_after_called

Subdomains

Defined In

Calls

Frequently Asked Questions

What does test_async_before_after_request() do?
test_async_before_after_request() is a function in the flask codebase, defined in tests/test_async.py.
Where is test_async_before_after_request() defined?
test_async_before_after_request() is defined in tests/test_async.py at line 97.
What does test_async_before_after_request() call?
test_async_before_after_request() calls 1 function(s): get.

Analyze Your Own Codebase

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

Try Supermodel Free