Home / Function/ test_dependency_contextvars() — fastapi Function Reference

test_dependency_contextvars() — fastapi Function Reference

Architecture documentation for the test_dependency_contextvars() function in test_dependency_contextvars.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  30aa2c17_3f99_ea44_d79f_854674ce8d20["test_dependency_contextvars()"]
  e41999b9_ee75_d78c_cb43_68601b39ae25["test_dependency_contextvars.py"]
  30aa2c17_3f99_ea44_d79f_854674ce8d20 -->|defined in| e41999b9_ee75_d78c_cb43_68601b39ae25
  style 30aa2c17_3f99_ea44_d79f_854674ce8d20 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_dependency_contextvars.py lines 41–52

def test_dependency_contextvars():
    """
    Check that custom middlewares don't affect the contextvar context for dependencies.

    The code before yield and the code after yield should be run in the same contextvar
    context, so that request_state_context_var.reset(contextvar_token).

    If they are run in a different context, that raises an error.
    """
    response = client.get("/user")
    assert response.json() == "deadpond"
    assert response.headers["custom"] == "foo"

Domain

Subdomains

Frequently Asked Questions

What does test_dependency_contextvars() do?
test_dependency_contextvars() is a function in the fastapi codebase, defined in tests/test_dependency_contextvars.py.
Where is test_dependency_contextvars() defined?
test_dependency_contextvars() is defined in tests/test_dependency_contextvars.py at line 41.

Analyze Your Own Codebase

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

Try Supermodel Free