Home / Function/ test_session_expiration() — flask Function Reference

test_session_expiration() — flask Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  66187784_41f5_1bc2_c577_4822ac2f4394["test_session_expiration()"]
  85bc4fb5_d1d7_a135_020d_69e052c12c0f["test_basic.py"]
  66187784_41f5_1bc2_c577_4822ac2f4394 -->|defined in| 85bc4fb5_d1d7_a135_020d_69e052c12c0f
  6ea1611d_2801_3cb5_a5b9_5b6403cc0537["index()"]
  66187784_41f5_1bc2_c577_4822ac2f4394 -->|calls| 6ea1611d_2801_3cb5_a5b9_5b6403cc0537
  style 66187784_41f5_1bc2_c577_4822ac2f4394 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_basic.py lines 402–431

def test_session_expiration(app, client):
    permanent = True

    @app.route("/")
    def index():
        flask.session["test"] = 42
        flask.session.permanent = permanent
        return ""

    @app.route("/test")
    def test():
        return str(flask.session.permanent)

    rv = client.get("/")
    assert "set-cookie" in rv.headers
    match = re.search(r"(?i)\bexpires=([^;]+)", rv.headers["set-cookie"])
    expires = parse_date(match.group())
    expected = datetime.now(timezone.utc) + app.permanent_session_lifetime
    assert expires.year == expected.year
    assert expires.month == expected.month
    assert expires.day == expected.day

    rv = client.get("/test")
    assert rv.data == b"True"

    permanent = False
    rv = client.get("/")
    assert "set-cookie" in rv.headers
    match = re.search(r"\bexpires=([^;]+)", rv.headers["set-cookie"])
    assert match is None

Subdomains

Defined In

Calls

Frequently Asked Questions

What does test_session_expiration() do?
test_session_expiration() is a function in the flask codebase, defined in tests/test_basic.py.
Where is test_session_expiration() defined?
test_session_expiration() is defined in tests/test_basic.py at line 402.
What does test_session_expiration() call?
test_session_expiration() calls 1 function(s): index.

Analyze Your Own Codebase

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

Try Supermodel Free