test_allow_inf_nan_in_enforcing.py — fastapi Source File
Architecture documentation for test_allow_inf_nan_in_enforcing.py, a python file in the fastapi codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR c64b1e9a_565e_98c8_cc75_c94e7bdb9418["test_allow_inf_nan_in_enforcing.py"] 0dda2280_3359_8460_301c_e98c77e78185["typing"] c64b1e9a_565e_98c8_cc75_c94e7bdb9418 --> 0dda2280_3359_8460_301c_e98c77e78185 5befe8bf_65d1_d058_6b78_4a597a8488e9["pytest"] c64b1e9a_565e_98c8_cc75_c94e7bdb9418 --> 5befe8bf_65d1_d058_6b78_4a597a8488e9 534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"] c64b1e9a_565e_98c8_cc75_c94e7bdb9418 --> 534f6e44_61b8_3c38_8b89_6934a6df9802 a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"] c64b1e9a_565e_98c8_cc75_c94e7bdb9418 --> a7c04dee_ee23_5891_b185_47ff6bed036d style c64b1e9a_565e_98c8_cc75_c94e7bdb9418 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from typing import Annotated
import pytest
from fastapi import Body, FastAPI, Query
from fastapi.testclient import TestClient
app = FastAPI()
@app.post("/")
async def get(
x: Annotated[float, Query(allow_inf_nan=True)] = 0,
y: Annotated[float, Query(allow_inf_nan=False)] = 0,
z: Annotated[float, Query()] = 0,
b: Annotated[float, Body(allow_inf_nan=False)] = 0,
) -> str:
return "OK"
client = TestClient(app)
@pytest.mark.parametrize(
"value,code",
[
("-1", 200),
("inf", 200),
("-inf", 200),
("nan", 200),
("0", 200),
("342", 200),
],
)
def test_allow_inf_nan_param_true(value: str, code: int):
response = client.post(f"/?x={value}")
assert response.status_code == code, response.text
@pytest.mark.parametrize(
"value,code",
[
("-1", 200),
("inf", 422),
("-inf", 422),
("nan", 422),
("0", 200),
("342", 200),
],
)
def test_allow_inf_nan_param_false(value: str, code: int):
response = client.post(f"/?y={value}")
assert response.status_code == code, response.text
@pytest.mark.parametrize(
"value,code",
[
("-1", 200),
("inf", 200),
("-inf", 200),
("nan", 200),
("0", 200),
("342", 200),
],
)
def test_allow_inf_nan_param_default(value: str, code: int):
response = client.post(f"/?z={value}")
assert response.status_code == code, response.text
@pytest.mark.parametrize(
"value,code",
[
("-1", 200),
("inf", 422),
("-inf", 422),
("nan", 422),
("0", 200),
("342", 200),
],
)
def test_allow_inf_nan_body(value: str, code: int):
response = client.post("/", json=value)
assert response.status_code == code, response.text
Domain
Subdomains
Functions
Dependencies
- __init__.py
- pytest
- testclient.py
- typing
Source
Frequently Asked Questions
What does test_allow_inf_nan_in_enforcing.py do?
test_allow_inf_nan_in_enforcing.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_allow_inf_nan_in_enforcing.py?
test_allow_inf_nan_in_enforcing.py defines 5 function(s): get, test_allow_inf_nan_body, test_allow_inf_nan_param_default, test_allow_inf_nan_param_false, test_allow_inf_nan_param_true.
What does test_allow_inf_nan_in_enforcing.py depend on?
test_allow_inf_nan_in_enforcing.py imports 4 module(s): __init__.py, pytest, testclient.py, typing.
Where is test_allow_inf_nan_in_enforcing.py in the architecture?
test_allow_inf_nan_in_enforcing.py is located at tests/test_allow_inf_nan_in_enforcing.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