test_dependency_after_yield_streaming.py — fastapi Source File
Architecture documentation for test_dependency_after_yield_streaming.py, a python file in the fastapi codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR c577968e_a400_0bfd_3947_3f6bc4f681d1["test_dependency_after_yield_streaming.py"] 07d79a2e_d4e9_0bbb_be90_936274444c8c["collections.abc"] c577968e_a400_0bfd_3947_3f6bc4f681d1 --> 07d79a2e_d4e9_0bbb_be90_936274444c8c a88eb002_9197_73f3_410d_ee5315767f34["contextlib"] c577968e_a400_0bfd_3947_3f6bc4f681d1 --> a88eb002_9197_73f3_410d_ee5315767f34 0dda2280_3359_8460_301c_e98c77e78185["typing"] c577968e_a400_0bfd_3947_3f6bc4f681d1 --> 0dda2280_3359_8460_301c_e98c77e78185 5befe8bf_65d1_d058_6b78_4a597a8488e9["pytest"] c577968e_a400_0bfd_3947_3f6bc4f681d1 --> 5befe8bf_65d1_d058_6b78_4a597a8488e9 534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"] c577968e_a400_0bfd_3947_3f6bc4f681d1 --> 534f6e44_61b8_3c38_8b89_6934a6df9802 967b6712_70e2_f5fa_f671_7c149857a445["responses.py"] c577968e_a400_0bfd_3947_3f6bc4f681d1 --> 967b6712_70e2_f5fa_f671_7c149857a445 a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"] c577968e_a400_0bfd_3947_3f6bc4f681d1 --> a7c04dee_ee23_5891_b185_47ff6bed036d style c577968e_a400_0bfd_3947_3f6bc4f681d1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from collections.abc import Generator
from contextlib import contextmanager
from typing import Annotated, Any
import pytest
from fastapi import Depends, FastAPI
from fastapi.responses import StreamingResponse
from fastapi.testclient import TestClient
class Session:
def __init__(self) -> None:
self.data = ["foo", "bar", "baz"]
self.open = True
def __iter__(self) -> Generator[str, None, None]:
for item in self.data:
if self.open:
yield item
else:
raise ValueError("Session closed")
@contextmanager
def acquire_session() -> Generator[Session, None, None]:
session = Session()
try:
yield session
finally:
session.open = False
def dep_session() -> Any:
with acquire_session() as s:
yield s
def broken_dep_session() -> Any:
with acquire_session() as s:
s.open = False
yield s
SessionDep = Annotated[Session, Depends(dep_session)]
BrokenSessionDep = Annotated[Session, Depends(broken_dep_session)]
app = FastAPI()
@app.get("/data")
def get_data(session: SessionDep) -> Any:
data = list(session)
return data
@app.get("/stream-simple")
def get_stream_simple(session: SessionDep) -> Any:
def iter_data():
yield from ["x", "y", "z"]
// ... (71 more lines)
Domain
Subdomains
Functions
- acquire_session()
- broken_dep_session()
- dep_session()
- get_broken_session_data()
- get_broken_session_stream()
- get_data()
- get_stream_session()
- get_stream_simple()
- test_broken_session_data()
- test_broken_session_data_no_raise()
- test_broken_session_stream_no_raise()
- test_broken_session_stream_raise()
- test_regular_no_stream()
- test_stream_session()
- test_stream_simple()
Classes
Dependencies
- __init__.py
- collections.abc
- contextlib
- pytest
- responses.py
- testclient.py
- typing
Source
Frequently Asked Questions
What does test_dependency_after_yield_streaming.py do?
test_dependency_after_yield_streaming.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Routing subdomain.
What functions are defined in test_dependency_after_yield_streaming.py?
test_dependency_after_yield_streaming.py defines 15 function(s): acquire_session, broken_dep_session, dep_session, get_broken_session_data, get_broken_session_stream, get_data, get_stream_session, get_stream_simple, test_broken_session_data, test_broken_session_data_no_raise, and 5 more.
What does test_dependency_after_yield_streaming.py depend on?
test_dependency_after_yield_streaming.py imports 7 module(s): __init__.py, collections.abc, contextlib, pytest, responses.py, testclient.py, typing.
Where is test_dependency_after_yield_streaming.py in the architecture?
test_dependency_after_yield_streaming.py is located at tests/test_dependency_after_yield_streaming.py (domain: FastAPI, subdomain: Routing, directory: tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free