- Sort Score
- Result 10 results
- Languages All
Results 131 - 140 of 617 for depende (0.04 sec)
-
tests/test_dependency_after_yield_raise.py
app = FastAPI() @app.get("/catching") def catching(d: Annotated[str, Depends(catching_dep)]) -> Any: raise CustomError("Simulated error during streaming") @app.get("/broken") def broken(d: Annotated[str, Depends(broken_dep)]) -> Any: return {"message": "all good?"} client = TestClient(app) def test_catching(): response = client.get("/catching") assert response.status_code == 418
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 21:25:59 UTC 2025 - 1.7K bytes - Viewed (0) -
tests/test_dependency_yield_except_httpexception.py
@app.put("/invalid-user/{user_id}") def put_invalid_user( user_id: str, name: str = Body(), db: dict = Depends(get_database) ): db[user_id] = name raise HTTPException(status_code=400, detail="Invalid user") @app.put("/user/{user_id}") def put_user(user_id: str, name: str = Body(), db: dict = Depends(get_database)): db[user_id] = name return {"message": "OK"} @pytest.fixture(autouse=True)
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Mon Sep 29 03:29:38 UTC 2025 - 1.9K bytes - Viewed (0) -
tests/test_dependency_contextvars.py
from collections.abc import Awaitable from contextvars import ContextVar from typing import Any, Callable, Optional from fastapi import Depends, FastAPI, Request, Response from fastapi.testclient import TestClient legacy_request_state_context_var: ContextVar[Optional[dict[str, Any]]] = ContextVar( "legacy_request_state_context_var", default=None ) app = FastAPI() async def set_up_request_state_dependency():
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 21:25:59 UTC 2025 - 1.5K bytes - Viewed (0) -
tests/test_security_api_key_cookie.py
from fastapi import Depends, FastAPI, Security from fastapi.security import APIKeyCookie from fastapi.testclient import TestClient from pydantic import BaseModel app = FastAPI() api_key = APIKeyCookie(name="key") class User(BaseModel): username: str def get_current_user(oauth_header: str = Security(api_key)): user = User(username=oauth_header) return user @app.get("/users/me")
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Mon Nov 24 19:03:06 UTC 2025 - 2K bytes - Viewed (0) -
docs_src/dependencies/tutorial001_02_an_py310.py
from typing import Annotated from fastapi import Depends, FastAPI app = FastAPI() async def common_parameters(q: str | None = None, skip: int = 0, limit: int = 100): return {"q": q, "skip": skip, "limit": limit} CommonsDep = Annotated[dict, Depends(common_parameters)] @app.get("/items/") async def read_items(commons: CommonsDep): return commons @app.get("/users/")
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 447 bytes - Viewed (0) -
impl/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/ProjectDependencyGraphStub.java
/** * A stub dependency graph that is custom-made for testing concurrent build graph evaluations. * <p> * Implements a graph as follows: * A has no dependencies * B depends on A * C depends on A * X depends on B & C * Y depends on B * Z depends on C * </p> * */ public class ProjectDependencyGraphStub implements ProjectDependencyGraph { public static final MavenProject A = new MavenProject();Registered: Sun Dec 28 03:35:09 UTC 2025 - Last Modified: Fri Jun 06 14:28:57 UTC 2025 - 8.6K bytes - Viewed (0) -
docs_src/dependencies/tutorial003_py310.py
from fastapi import Depends, FastAPI app = FastAPI() fake_items_db = [{"item_name": "Foo"}, {"item_name": "Bar"}, {"item_name": "Baz"}] class CommonQueryParams: def __init__(self, q: str | None = None, skip: int = 0, limit: int = 100): self.q = q self.skip = skip self.limit = limit @app.get("/items/") async def read_items(commons=Depends(CommonQueryParams)): response = {} if commons.q:
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Fri Jan 07 14:11:31 UTC 2022 - 603 bytes - Viewed (0) -
tests/test_security_api_key_cookie_description.py
from fastapi import Depends, FastAPI, Security from fastapi.security import APIKeyCookie from fastapi.testclient import TestClient from pydantic import BaseModel app = FastAPI() api_key = APIKeyCookie(name="key", description="An API Cookie Key") class User(BaseModel): username: str def get_current_user(oauth_header: str = Security(api_key)): user = User(username=oauth_header) return user
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Mon Nov 24 19:03:06 UTC 2025 - 2.1K bytes - Viewed (0) -
docs_src/dependencies/tutorial008e_py39.py
from fastapi import Depends, FastAPI app = FastAPI() def get_username(): try: yield "Rick" finally: print("Cleanup up before response is sent") @app.get("/users/me") def get_user_me(username: str = Depends(get_username, scope="function")):
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 289 bytes - Viewed (0) -
docs_src/background_tasks/tutorial002_py310.py
from fastapi import BackgroundTasks, Depends, FastAPI app = FastAPI() def write_log(message: str): with open("log.txt", mode="a") as log: log.write(message) def get_query(background_tasks: BackgroundTasks, q: str | None = None): if q: message = f"found query: {q}\n" background_tasks.add_task(write_log, message) return q @app.post("/send-notification/{email}")
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Fri Jan 07 14:11:31 UTC 2022 - 643 bytes - Viewed (0)