test_tutorial001.py — fastapi Source File
Architecture documentation for test_tutorial001.py, a python file in the fastapi codebase. 10 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR ff56476d_b0e9_82b7_ad6a_ed215d04210f["test_tutorial001.py"] 83e01a9c_50a9_bec9_6f86_8e729106de01["importlib"] ff56476d_b0e9_82b7_ad6a_ed215d04210f --> 83e01a9c_50a9_bec9_6f86_8e729106de01 9c2c9cad_dfd2_7d1a_1c6d_b8a448285db4["warnings"] ff56476d_b0e9_82b7_ad6a_ed215d04210f --> 9c2c9cad_dfd2_7d1a_1c6d_b8a448285db4 5befe8bf_65d1_d058_6b78_4a597a8488e9["pytest"] ff56476d_b0e9_82b7_ad6a_ed215d04210f --> 5befe8bf_65d1_d058_6b78_4a597a8488e9 752ca3d8_e45b_84ed_d1a1_588cbc236b65["dirty_equals"] ff56476d_b0e9_82b7_ad6a_ed215d04210f --> 752ca3d8_e45b_84ed_d1a1_588cbc236b65 a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"] ff56476d_b0e9_82b7_ad6a_ed215d04210f --> a7c04dee_ee23_5891_b185_47ff6bed036d a7f4e7b0_9725_db90_5cbc_7ca8211b323a["inline_snapshot"] ff56476d_b0e9_82b7_ad6a_ed215d04210f --> a7f4e7b0_9725_db90_5cbc_7ca8211b323a 66098adb_f423_c165_4fdd_f162b4f94613["sqlalchemy"] ff56476d_b0e9_82b7_ad6a_ed215d04210f --> 66098adb_f423_c165_4fdd_f162b4f94613 bf11c16a_04e7_1fd0_b317_a1196fc34aad["sqlmodel"] ff56476d_b0e9_82b7_ad6a_ed215d04210f --> bf11c16a_04e7_1fd0_b317_a1196fc34aad e2d877c5_ba6d_83fd_271c_fa7fee12665a["sqlmodel.main"] ff56476d_b0e9_82b7_ad6a_ed215d04210f --> e2d877c5_ba6d_83fd_271c_fa7fee12665a 8fd7072e_05b0_6622_0f14_e1e357032855["utils.py"] ff56476d_b0e9_82b7_ad6a_ed215d04210f --> 8fd7072e_05b0_6622_0f14_e1e357032855 style ff56476d_b0e9_82b7_ad6a_ed215d04210f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import importlib
import warnings
import pytest
from dirty_equals import IsInt
from fastapi.testclient import TestClient
from inline_snapshot import snapshot
from sqlalchemy import StaticPool
from sqlmodel import SQLModel, create_engine
from sqlmodel.main import default_registry
from tests.utils import needs_py310
def clear_sqlmodel():
# Clear the tables in the metadata for the default base model
SQLModel.metadata.clear()
# Clear the Models associated with the registry, to avoid warnings
default_registry.dispose()
@pytest.fixture(
name="client",
params=[
pytest.param("tutorial001_py39"),
pytest.param("tutorial001_py310", marks=needs_py310),
pytest.param("tutorial001_an_py39"),
pytest.param("tutorial001_an_py310", marks=needs_py310),
],
)
def get_client(request: pytest.FixtureRequest):
clear_sqlmodel()
# TODO: remove when updating SQL tutorial to use new lifespan API
with warnings.catch_warnings(record=True):
warnings.simplefilter("always")
mod = importlib.import_module(f"docs_src.sql_databases.{request.param}")
clear_sqlmodel()
importlib.reload(mod)
mod.sqlite_url = "sqlite://"
mod.engine = create_engine(
mod.sqlite_url, connect_args={"check_same_thread": False}, poolclass=StaticPool
)
with TestClient(mod.app) as c:
yield c
# Clean up connection explicitly to avoid resource warning
mod.engine.dispose()
def test_crud_app(client: TestClient):
# TODO: this warns that SQLModel.from_orm is deprecated in Pydantic v1, refactor
# this if using obj.model_validate becomes independent of Pydantic v2
with warnings.catch_warnings(record=True):
warnings.simplefilter("always")
# No heroes before creating
response = client.get("heroes/")
assert response.status_code == 200, response.text
assert response.json() == []
# Create a hero
// ... (298 more lines)
Domain
Subdomains
Dependencies
- dirty_equals
- importlib
- inline_snapshot
- pytest
- sqlalchemy
- sqlmodel
- sqlmodel.main
- testclient.py
- utils.py
- warnings
Source
Frequently Asked Questions
What does test_tutorial001.py do?
test_tutorial001.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Applications subdomain.
What functions are defined in test_tutorial001.py?
test_tutorial001.py defines 4 function(s): clear_sqlmodel, get_client, test_crud_app, test_openapi_schema.
What does test_tutorial001.py depend on?
test_tutorial001.py imports 10 module(s): dirty_equals, importlib, inline_snapshot, pytest, sqlalchemy, sqlmodel, sqlmodel.main, testclient.py, and 2 more.
Where is test_tutorial001.py in the architecture?
test_tutorial001.py is located at tests/test_tutorial/test_sql_databases/test_tutorial001.py (domain: FastAPI, subdomain: Applications, directory: tests/test_tutorial/test_sql_databases).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free