Home / Function/ test_read_items() — fastapi Function Reference

test_read_items() — fastapi Function Reference

Architecture documentation for the test_read_items() function in tutorial004_py39.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  f9baa10e_e32e_7960_aee3_8098f7b6ca60["test_read_items()"]
  928274a7_8738_3478_e87f_645fde08f652["tutorial004_py39.py"]
  f9baa10e_e32e_7960_aee3_8098f7b6ca60 -->|defined in| 928274a7_8738_3478_e87f_645fde08f652
  1b3ae849_cbe6_6c35_8431_f04ae1baacc2["test_main()"]
  1b3ae849_cbe6_6c35_8431_f04ae1baacc2 -->|calls| f9baa10e_e32e_7960_aee3_8098f7b6ca60
  style f9baa10e_e32e_7960_aee3_8098f7b6ca60 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

docs_src/app_testing/tutorial004_py39.py lines 26–43

def test_read_items():
    # Before the lifespan starts, "items" is still empty
    assert items == {}

    with TestClient(app) as client:
        # Inside the "with TestClient" block, the lifespan starts and items added
        assert items == {"foo": {"name": "Fighters"}, "bar": {"name": "Tenders"}}

        response = client.get("/items/foo")
        assert response.status_code == 200
        assert response.json() == {"name": "Fighters"}

        # After the requests is done, the items are still there
        assert items == {"foo": {"name": "Fighters"}, "bar": {"name": "Tenders"}}

    # The end of the "with TestClient" block simulates terminating the app, so
    # the lifespan ends and items are cleaned up
    assert items == {}

Domain

Subdomains

Called By

Frequently Asked Questions

What does test_read_items() do?
test_read_items() is a function in the fastapi codebase, defined in docs_src/app_testing/tutorial004_py39.py.
Where is test_read_items() defined?
test_read_items() is defined in docs_src/app_testing/tutorial004_py39.py at line 26.
What calls test_read_items()?
test_read_items() is called by 1 function(s): test_main.

Analyze Your Own Codebase

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

Try Supermodel Free