Home / Function/ test_init_once() — flask Function Reference

test_init_once() — flask Function Reference

Architecture documentation for the test_init_once() function in test_views.py from the flask codebase.

Entity Profile

Dependency Diagram

graph TD
  0bff2a10_d7ca_3eb3_508e_8e39e05d8ad0["test_init_once()"]
  dc72c3f0_27a2_eeb5_19d5_19d3385508ed["test_views.py"]
  0bff2a10_d7ca_3eb3_508e_8e39e05d8ad0 -->|defined in| dc72c3f0_27a2_eeb5_19d5_19d3385508ed
  4d3129d2_54db_e673_646a_eba9e00383fb["get()"]
  0bff2a10_d7ca_3eb3_508e_8e39e05d8ad0 -->|calls| 4d3129d2_54db_e673_646a_eba9e00383fb
  c133540b_f6d4_d751_3d54_54f79e3eab17["dispatch_request()"]
  0bff2a10_d7ca_3eb3_508e_8e39e05d8ad0 -->|calls| c133540b_f6d4_d751_3d54_54f79e3eab17
  style 0bff2a10_d7ca_3eb3_508e_8e39e05d8ad0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_views.py lines 245–260

def test_init_once(app, client):
    n = 0

    class CountInit(flask.views.View):
        init_every_request = False

        def __init__(self):
            nonlocal n
            n += 1

        def dispatch_request(self):
            return str(n)

    app.add_url_rule("/", view_func=CountInit.as_view("index"))
    assert client.get("/").data == b"1"
    assert client.get("/").data == b"1"

Subdomains

Defined In

Frequently Asked Questions

What does test_init_once() do?
test_init_once() is a function in the flask codebase, defined in tests/test_views.py.
Where is test_init_once() defined?
test_init_once() is defined in tests/test_views.py at line 245.
What does test_init_once() call?
test_init_once() calls 2 function(s): dispatch_request, get.

Analyze Your Own Codebase

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

Try Supermodel Free