Home / File/ test_dependency_contextmanager.py — fastapi Source File

test_dependency_contextmanager.py — fastapi Source File

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

File python FastAPI Applications 5 imports 48 functions 3 classes

Entity Profile

Dependency Diagram

graph LR
  952bbb41_0c47_a7fe_aee8_884380d032f7["test_dependency_contextmanager.py"]
  c1ef60e8_e635_2e82_29e5_a79e03e975d6["json"]
  952bbb41_0c47_a7fe_aee8_884380d032f7 --> c1ef60e8_e635_2e82_29e5_a79e03e975d6
  5befe8bf_65d1_d058_6b78_4a597a8488e9["pytest"]
  952bbb41_0c47_a7fe_aee8_884380d032f7 --> 5befe8bf_65d1_d058_6b78_4a597a8488e9
  534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"]
  952bbb41_0c47_a7fe_aee8_884380d032f7 --> 534f6e44_61b8_3c38_8b89_6934a6df9802
  967b6712_70e2_f5fa_f671_7c149857a445["responses.py"]
  952bbb41_0c47_a7fe_aee8_884380d032f7 --> 967b6712_70e2_f5fa_f671_7c149857a445
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  952bbb41_0c47_a7fe_aee8_884380d032f7 --> a7c04dee_ee23_5891_b185_47ff6bed036d
  style 952bbb41_0c47_a7fe_aee8_884380d032f7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import json

import pytest
from fastapi import BackgroundTasks, Depends, FastAPI
from fastapi.responses import StreamingResponse
from fastapi.testclient import TestClient

app = FastAPI()
state = {
    "/async": "asyncgen not started",
    "/sync": "generator not started",
    "/async_raise": "asyncgen raise not started",
    "/sync_raise": "generator raise not started",
    "context_a": "not started a",
    "context_b": "not started b",
    "bg": "not set",
    "sync_bg": "not set",
}

errors = []


async def get_state():
    return state


class AsyncDependencyError(Exception):
    pass


class SyncDependencyError(Exception):
    pass


class OtherDependencyError(Exception):
    pass


async def asyncgen_state(state: dict[str, str] = Depends(get_state)):
    state["/async"] = "asyncgen started"
    yield state["/async"]
    state["/async"] = "asyncgen completed"


def generator_state(state: dict[str, str] = Depends(get_state)):
    state["/sync"] = "generator started"
    yield state["/sync"]
    state["/sync"] = "generator completed"


async def asyncgen_state_try(state: dict[str, str] = Depends(get_state)):
    state["/async_raise"] = "asyncgen raise started"
    try:
        yield state["/async_raise"]
    except AsyncDependencyError:
        errors.append("/async_raise")
        raise
    finally:
        state["/async_raise"] = "asyncgen raise finalized"

// ... (340 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does test_dependency_contextmanager.py do?
test_dependency_contextmanager.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_dependency_contextmanager.py?
test_dependency_contextmanager.py defines 48 function(s): asyncgen_state, asyncgen_state_try, context_a, context_b, generator_state, generator_state_try, get_async, get_async_raise, get_async_raise_other, get_context_b, and 38 more.
What does test_dependency_contextmanager.py depend on?
test_dependency_contextmanager.py imports 5 module(s): __init__.py, json, pytest, responses.py, testclient.py.
Where is test_dependency_contextmanager.py in the architecture?
test_dependency_contextmanager.py is located at tests/test_dependency_contextmanager.py (domain: FastAPI, subdomain: Applications, directory: tests).

Analyze Your Own Codebase

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

Try Supermodel Free