Home / File/ test_regex_deprecated_body.py — fastapi Source File

test_regex_deprecated_body.py — fastapi Source File

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

File python FastAPI Routing 8 imports 5 functions

Entity Profile

Dependency Diagram

graph LR
  8f2fab8a_e459_dbe9_dda2_fbbd4b149368["test_regex_deprecated_body.py"]
  8fd7072e_05b0_6622_0f14_e1e357032855["utils.py"]
  8f2fab8a_e459_dbe9_dda2_fbbd4b149368 --> 8fd7072e_05b0_6622_0f14_e1e357032855
  0dda2280_3359_8460_301c_e98c77e78185["typing"]
  8f2fab8a_e459_dbe9_dda2_fbbd4b149368 --> 0dda2280_3359_8460_301c_e98c77e78185
  5befe8bf_65d1_d058_6b78_4a597a8488e9["pytest"]
  8f2fab8a_e459_dbe9_dda2_fbbd4b149368 --> 5befe8bf_65d1_d058_6b78_4a597a8488e9
  534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"]
  8f2fab8a_e459_dbe9_dda2_fbbd4b149368 --> 534f6e44_61b8_3c38_8b89_6934a6df9802
  01c652c5_d85c_f45e_848e_412c94ea4172["exceptions.py"]
  8f2fab8a_e459_dbe9_dda2_fbbd4b149368 --> 01c652c5_d85c_f45e_848e_412c94ea4172
  188b7cd0_ba07_6be7_094a_820e577cc47b["FastAPIDeprecationWarning"]
  8f2fab8a_e459_dbe9_dda2_fbbd4b149368 --> 188b7cd0_ba07_6be7_094a_820e577cc47b
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  8f2fab8a_e459_dbe9_dda2_fbbd4b149368 --> a7c04dee_ee23_5891_b185_47ff6bed036d
  a7f4e7b0_9725_db90_5cbc_7ca8211b323a["inline_snapshot"]
  8f2fab8a_e459_dbe9_dda2_fbbd4b149368 --> a7f4e7b0_9725_db90_5cbc_7ca8211b323a
  style 8f2fab8a_e459_dbe9_dda2_fbbd4b149368 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from typing import Annotated

import pytest
from fastapi import FastAPI, Form
from fastapi.exceptions import FastAPIDeprecationWarning
from fastapi.testclient import TestClient
from inline_snapshot import snapshot

from .utils import needs_py310


def get_client():
    app = FastAPI()
    with pytest.warns(FastAPIDeprecationWarning):

        @app.post("/items/")
        async def read_items(
            q: Annotated[str | None, Form(regex="^fixedquery$")] = None,
        ):
            if q:
                return f"Hello {q}"
            else:
                return "Hello World"

    client = TestClient(app)
    return client


@needs_py310
def test_no_query():
    client = get_client()
    response = client.post("/items/")
    assert response.status_code == 200
    assert response.json() == "Hello World"


@needs_py310
def test_q_fixedquery():
    client = get_client()
    response = client.post("/items/", data={"q": "fixedquery"})
    assert response.status_code == 200
    assert response.json() == "Hello fixedquery"


@needs_py310
def test_query_nonregexquery():
    client = get_client()
    response = client.post("/items/", data={"q": "nonregexquery"})
    assert response.status_code == 422
    assert response.json() == {
        "detail": [
            {
                "type": "string_pattern_mismatch",
                "loc": ["body", "q"],
                "msg": "String should match pattern '^fixedquery$'",
                "input": "nonregexquery",
                "ctx": {"pattern": "^fixedquery$"},
            }
        ]
    }
// ... (95 more lines)

Domain

Subdomains

Frequently Asked Questions

What does test_regex_deprecated_body.py do?
test_regex_deprecated_body.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_regex_deprecated_body.py?
test_regex_deprecated_body.py defines 5 function(s): get_client, test_no_query, test_openapi_schema, test_q_fixedquery, test_query_nonregexquery.
What does test_regex_deprecated_body.py depend on?
test_regex_deprecated_body.py imports 8 module(s): FastAPIDeprecationWarning, __init__.py, exceptions.py, inline_snapshot, pytest, testclient.py, typing, utils.py.
Where is test_regex_deprecated_body.py in the architecture?
test_regex_deprecated_body.py is located at tests/test_regex_deprecated_body.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