Home / File/ test_wrapped_method_forward_reference.py — fastapi Source File

test_wrapped_method_forward_reference.py — fastapi Source File

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

File python FastAPI Responses 5 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  25760a4c_6a1b_5167_f4ca_a5b253a766bd["test_wrapped_method_forward_reference.py"]
  a879e73b_549a_b783_7153_27886bb4ddd0["forward_reference_type.py"]
  25760a4c_6a1b_5167_f4ca_a5b253a766bd --> a879e73b_549a_b783_7153_27886bb4ddd0
  e6f1e7af_1273_4b6c_1600_542dcae88e84["forwardref_method"]
  25760a4c_6a1b_5167_f4ca_a5b253a766bd --> e6f1e7af_1273_4b6c_1600_542dcae88e84
  958aa7af_9d63_fe0c_3544_91dd93294508["functools"]
  25760a4c_6a1b_5167_f4ca_a5b253a766bd --> 958aa7af_9d63_fe0c_3544_91dd93294508
  534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"]
  25760a4c_6a1b_5167_f4ca_a5b253a766bd --> 534f6e44_61b8_3c38_8b89_6934a6df9802
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  25760a4c_6a1b_5167_f4ca_a5b253a766bd --> a7c04dee_ee23_5891_b185_47ff6bed036d
  style 25760a4c_6a1b_5167_f4ca_a5b253a766bd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import functools

from fastapi import FastAPI
from fastapi.testclient import TestClient

from .forward_reference_type import forwardref_method


def passthrough(f):
    @functools.wraps(f)
    def method(*args, **kwargs):
        return f(*args, **kwargs)

    return method


def test_wrapped_method_type_inference():
    """
    Regression test ensuring that when a method imported from another module
    is decorated with something that sets the __wrapped__ attribute (functools.wraps),
    then the types are still processed correctly, including dereferencing of forward
    references.
    """
    app = FastAPI()
    client = TestClient(app)
    app.post("/endpoint")(passthrough(forwardref_method))
    app.post("/endpoint2")(passthrough(passthrough(forwardref_method)))
    with client:
        response = client.post("/endpoint", json={"input": {"x": 0}})
        response2 = client.post("/endpoint2", json={"input": {"x": 0}})
    assert response.json() == response2.json() == {"x": 1}

Domain

Subdomains

Frequently Asked Questions

What does test_wrapped_method_forward_reference.py do?
test_wrapped_method_forward_reference.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Responses subdomain.
What functions are defined in test_wrapped_method_forward_reference.py?
test_wrapped_method_forward_reference.py defines 2 function(s): passthrough, test_wrapped_method_type_inference.
What does test_wrapped_method_forward_reference.py depend on?
test_wrapped_method_forward_reference.py imports 5 module(s): __init__.py, forward_reference_type.py, forwardref_method, functools, testclient.py.
Where is test_wrapped_method_forward_reference.py in the architecture?
test_wrapped_method_forward_reference.py is located at tests/test_wrapped_method_forward_reference.py (domain: FastAPI, subdomain: Responses, directory: tests).

Analyze Your Own Codebase

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

Try Supermodel Free