test_background_tasks() — fastapi Function Reference
Architecture documentation for the test_background_tasks() function in test_dependency_contextmanager.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD 386e2cb4_aaa8_6f87_03aa_9fdf6175273e["test_background_tasks()"] 952bbb41_0c47_a7fe_aee8_884380d032f7["test_dependency_contextmanager.py"] 386e2cb4_aaa8_6f87_03aa_9fdf6175273e -->|defined in| 952bbb41_0c47_a7fe_aee8_884380d032f7 style 386e2cb4_aaa8_6f87_03aa_9fdf6175273e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_dependency_contextmanager.py lines 281–293
def test_background_tasks():
response = client.get("/context_b_bg")
data = response.json()
assert data["context_b"] == "started b"
assert data["context_a"] == "started a"
assert data["bg"] == "not set"
middleware_state = json.loads(response.headers["x-state"])
assert middleware_state["context_b"] == "started b"
assert middleware_state["context_a"] == "started a"
assert middleware_state["bg"] == "not set"
assert state["context_b"] == "finished b with a: started a"
assert state["context_a"] == "finished a"
assert state["bg"] == "bg set - b: started b - a: started a"
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_background_tasks() do?
test_background_tasks() is a function in the fastapi codebase, defined in tests/test_dependency_contextmanager.py.
Where is test_background_tasks() defined?
test_background_tasks() is defined in tests/test_dependency_contextmanager.py at line 281.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free