Home / Function/ test_login() — flask Function Reference

test_login() — flask Function Reference

Architecture documentation for the test_login() function in test_auth.py from the flask codebase.

Entity Profile

Dependency Diagram

graph TD
  03a1ae6c_ef51_24e5_e48e_226f841b272d["test_login()"]
  f150d57d_79dc_267c_54f5_64b159a4b522["test_auth.py"]
  03a1ae6c_ef51_24e5_e48e_226f841b272d -->|defined in| f150d57d_79dc_267c_54f5_64b159a4b522
  style 03a1ae6c_ef51_24e5_e48e_226f841b272d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

examples/tutorial/tests/test_auth.py lines 39–52

def test_login(client, auth):
    # test that viewing the page renders without template errors
    assert client.get("/auth/login").status_code == 200

    # test that successful login redirects to the index page
    response = auth.login()
    assert response.headers["Location"] == "/"

    # login request set the user_id in the session
    # check that the user is loaded from the session
    with client:
        client.get("/")
        assert session["user_id"] == 1
        assert g.user["username"] == "test"

Subdomains

Frequently Asked Questions

What does test_login() do?
test_login() is a function in the flask codebase, defined in examples/tutorial/tests/test_auth.py.
Where is test_login() defined?
test_login() is defined in examples/tutorial/tests/test_auth.py at line 39.

Analyze Your Own Codebase

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

Try Supermodel Free