- Sort Score
- Result 10 results
- Languages All
Results 21 - 30 of 1,452 for def (0.01 sec)
-
tests/test_skip_defaults.py
) def get_exclude_unset_none() -> ModelDefaults: return ModelDefaults(x=None, y="y") client = TestClient(app) def test_return_defaults(): response = client.get("/") assert response.json() == {"sub": {}} def test_return_exclude_unset(): response = client.get("/exclude_unset") assert response.json() == {"x": None, "y": "y"} def test_return_exclude_defaults():
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jul 07 17:12:13 UTC 2023 - 2K bytes - Viewed (0) -
tests/test_inherited_custom_class.py
from .utils import needs_pydanticv1, needs_pydanticv2 class MyUuid: def __init__(self, uuid_string: str): self.uuid = uuid_string def __str__(self): return self.uuid @property # type: ignore def __class__(self): return uuid.UUID @property def __dict__(self): """Spoof a missing __dict__ by raising TypeError, this is how
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Aug 17 04:13:50 UTC 2024 - 3K bytes - Viewed (0) -
fastapi/datastructures.py
""" def __init__(self, value: Any): self.value = value def __bool__(self) -> bool: return bool(self.value) def __eq__(self, o: object) -> bool: return isinstance(o, DefaultPlaceholder) and o.value == self.value DefaultType = TypeVar("DefaultType") def Default(value: DefaultType) -> DefaultType: """ You shouldn't use this function directly.
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Tue Apr 02 02:48:51 UTC 2024 - 5.6K bytes - Viewed (0) -
tests/test_response_model_include_exclude.py
response_model_include={"baz": ..., "ref": {"foo"}}, ) def simple_include(): return Model2( ref=Model1(foo="simple_include model foo", bar="simple_include model bar"), baz="simple_include model2 baz", ) @app.get( "/simple_include_dict", response_model=Model2, response_model_include={"baz": ..., "ref": {"foo"}}, ) def simple_include_dict(): return { "ref": {
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Mon Jul 19 19:14:58 UTC 2021 - 4K bytes - Viewed (0) -
tests/test_starlette_urlconvertors.py
app = FastAPI() @app.get("/int/{param:int}") def int_convertor(param: int = Path()): return {"int": param} @app.get("/float/{param:float}") def float_convertor(param: float = Path()): return {"float": param} @app.get("/path/{param:path}") def path_convertor(param: str = Path()): return {"path": param} @app.get("/query/") def query_convertor(param: str = Query()):
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Nov 27 14:46:06 UTC 2022 - 1.7K bytes - Viewed (0) -
tests/test_query.py
] } ) def test_query_optional(): response = client.get("/query/optional") assert response.status_code == 200 assert response.json() == "foo bar" def test_query_optional_query_baz(): response = client.get("/query/optional?query=baz") assert response.status_code == 200 assert response.json() == "foo bar baz" def test_query_optional_not_declared_baz():
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Apr 18 21:56:59 UTC 2024 - 11.4K bytes - Viewed (0) -
tests/test_ws_dependencies.py
from fastapi import APIRouter, Depends, FastAPI, WebSocket from fastapi.testclient import TestClient from typing_extensions import Annotated def dependency_list() -> List[str]: return [] DepList = Annotated[List[str], Depends(dependency_list)] def create_dependency(name: str): def fun(deps: DepList): deps.append(name) return Depends(fun)
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Jun 11 20:35:39 UTC 2023 - 2.1K bytes - Viewed (0) -
tests/test_dependency_overrides.py
router = APIRouter() async def common_parameters(q: str, skip: int = 0, limit: int = 100): return {"q": q, "skip": skip, "limit": limit} @app.get("/main-depends/") async def main_depends(commons: dict = Depends(common_parameters)): return {"in": "main-depends", "params": commons} @app.get("/decorator-depends/", dependencies=[Depends(common_parameters)]) async def decorator_depends():
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Apr 18 19:40:57 UTC 2024 - 15.4K bytes - Viewed (0) -
tests/test_dependency_security_overrides.py
app = FastAPI() def get_user(required_scopes: SecurityScopes): return "john", required_scopes.scopes def get_user_override(required_scopes: SecurityScopes): return "alice", required_scopes.scopes def get_data(): return [1, 2, 3] def get_data_override(): return [3, 4, 5] @app.get("/user") def read_user(
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Jun 14 15:54:46 UTC 2020 - 1.4K bytes - Viewed (0) -
tests/test_invalid_sequence_param.py
from fastapi import FastAPI, Query from pydantic import BaseModel def test_invalid_sequence(): with pytest.raises(AssertionError): app = FastAPI() class Item(BaseModel): title: str @app.get("/items/") def read_items(q: List[Item] = Query(default=None)): pass # pragma: no cover def test_invalid_tuple(): with pytest.raises(AssertionError):
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri May 13 23:38:22 UTC 2022 - 1.2K bytes - Viewed (0)