Home / File/ test_dependency_yield_scope.py — fastapi Source File

test_dependency_yield_scope.py — fastapi Source File

Architecture documentation for test_dependency_yield_scope.py, a python file in the fastapi codebase. 8 imports, 0 dependents.

File python FastAPI Routing 8 imports 23 functions 2 classes

Entity Profile

Dependency Diagram

graph LR
  1d6a5359_eb63_e124_a768_36c861660b1a["test_dependency_yield_scope.py"]
  c1ef60e8_e635_2e82_29e5_a79e03e975d6["json"]
  1d6a5359_eb63_e124_a768_36c861660b1a --> c1ef60e8_e635_2e82_29e5_a79e03e975d6
  0dda2280_3359_8460_301c_e98c77e78185["typing"]
  1d6a5359_eb63_e124_a768_36c861660b1a --> 0dda2280_3359_8460_301c_e98c77e78185
  5befe8bf_65d1_d058_6b78_4a597a8488e9["pytest"]
  1d6a5359_eb63_e124_a768_36c861660b1a --> 5befe8bf_65d1_d058_6b78_4a597a8488e9
  534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"]
  1d6a5359_eb63_e124_a768_36c861660b1a --> 534f6e44_61b8_3c38_8b89_6934a6df9802
  01c652c5_d85c_f45e_848e_412c94ea4172["exceptions.py"]
  1d6a5359_eb63_e124_a768_36c861660b1a --> 01c652c5_d85c_f45e_848e_412c94ea4172
  2d54c1ec_3e75_6f8e_face_5433598e4278["FastAPIError"]
  1d6a5359_eb63_e124_a768_36c861660b1a --> 2d54c1ec_3e75_6f8e_face_5433598e4278
  967b6712_70e2_f5fa_f671_7c149857a445["responses.py"]
  1d6a5359_eb63_e124_a768_36c861660b1a --> 967b6712_70e2_f5fa_f671_7c149857a445
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  1d6a5359_eb63_e124_a768_36c861660b1a --> a7c04dee_ee23_5891_b185_47ff6bed036d
  style 1d6a5359_eb63_e124_a768_36c861660b1a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import json
from typing import Annotated, Any

import pytest
from fastapi import APIRouter, Depends, FastAPI, HTTPException
from fastapi.exceptions import FastAPIError
from fastapi.responses import StreamingResponse
from fastapi.testclient import TestClient


class Session:
    def __init__(self) -> None:
        self.open = True


def dep_session() -> Any:
    s = Session()
    yield s
    s.open = False


def raise_after_yield() -> Any:
    yield
    raise HTTPException(status_code=503, detail="Exception after yield")


SessionFuncDep = Annotated[Session, Depends(dep_session, scope="function")]
SessionRequestDep = Annotated[Session, Depends(dep_session, scope="request")]
SessionDefaultDep = Annotated[Session, Depends(dep_session)]


class NamedSession:
    def __init__(self, name: str = "default") -> None:
        self.name = name
        self.open = True


def get_named_session(session: SessionRequestDep, session_b: SessionDefaultDep) -> Any:
    assert session is session_b
    named_session = NamedSession(name="named")
    yield named_session, session_b
    named_session.open = False


NamedSessionsDep = Annotated[tuple[NamedSession, Session], Depends(get_named_session)]


def get_named_func_session(session: SessionFuncDep) -> Any:
    named_session = NamedSession(name="named")
    yield named_session, session
    named_session.open = False


def get_named_regular_func_session(session: SessionFuncDep) -> Any:
    named_session = NamedSession(name="named")
    return named_session, session


BrokenSessionsDep = Annotated[
    tuple[NamedSession, Session], Depends(get_named_func_session)
// ... (186 more lines)

Domain

Subdomains

Frequently Asked Questions

What does test_dependency_yield_scope.py do?
test_dependency_yield_scope.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_yield_scope.py?
test_dependency_yield_scope.py defines 23 function(s): dep_session, function_scope, get_index, get_named_func_session, get_named_function_scope, get_named_regular_func_session, get_named_session, get_regular_function_scope, get_stream_session, get_sub, and 13 more.
What does test_dependency_yield_scope.py depend on?
test_dependency_yield_scope.py imports 8 module(s): FastAPIError, __init__.py, exceptions.py, json, pytest, responses.py, testclient.py, typing.
Where is test_dependency_yield_scope.py in the architecture?
test_dependency_yield_scope.py is located at tests/test_dependency_yield_scope.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