- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 21 for dependency_overrides (0.15 sec)
-
tests/test_dependency_overrides.py
) def test_override_simple(url, status_code, expected): app.dependency_overrides[common_parameters] = overrider_dependency_simple response = client.get(url) assert response.status_code == status_code assert response.json() == expected app.dependency_overrides = {} def test_override_with_sub_main_depends(): app.dependency_overrides[common_parameters] = overrider_dependency_with_sub
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Apr 18 19:40:57 UTC 2024 - 15.4K bytes - Viewed (0) -
docs/en/docs/advanced/testing-dependencies.md
In this case, you can override the dependency that calls that provider, and use a custom dependency that returns a mock user, only for your tests. ### Use the `app.dependency_overrides` attribute For these cases, your **FastAPI** application has an attribute `app.dependency_overrides`, it is a simple `dict`.
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 2.9K bytes - Viewed (0) -
docs/em/docs/advanced/testing-dependencies.md
👆 🎲 💚 💯 🔢 🐕🦺 🕐, ✋️ 🚫 🎯 🤙 ⚫️ 🔠 💯 👈 🏃. 👉 💼, 👆 💪 🔐 🔗 👈 🤙 👈 🐕🦺, & ⚙️ 🛃 🔗 👈 📨 🎁 👩💻, 🕴 👆 💯. ### ⚙️ `app.dependency_overrides` 🔢 👫 💼, 👆 **FastAPI** 🈸 ✔️ 🔢 `app.dependency_overrides`, ⚫️ 🙅 `dict`. 🔐 🔗 🔬, 👆 🚮 🔑 ⏮️ 🔗 (🔢), & 💲, 👆 🔗 🔐 (➕1️⃣ 🔢). & ⤴️ **FastAPI** 🔜 🤙 👈 🔐 ↩️ ⏮️ 🔗. ```Python hl_lines="28-29 32"
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 1.7K bytes - Viewed (0) -
docs/de/docs/advanced/testing-dependencies.md
### Verwenden Sie das Attribut `app.dependency_overrides`. Für diese Fälle verfügt Ihre **FastAPI**-Anwendung über das Attribut `app.dependency_overrides`, bei diesem handelt sich um ein einfaches `dict`.
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 3.5K bytes - Viewed (0) -
docs/zh/docs/advanced/testing-dependencies.md
常见实例是调用外部第三方身份验证应用。 向第三方应用发送令牌,然后返回经验证的用户。 但第三方服务商处理每次请求都可能会收费,并且耗时通常也比调用写死的模拟测试用户更长。 一般只要测试一次外部验证应用就够了,不必每次测试都去调用。 此时,最好覆盖调用外部验证应用的依赖项,使用返回模拟测试用户的自定义依赖项就可以了。 ### 使用 `app.dependency_overrides` 属性 对于这些用例,**FastAPI** 应用支持 `app.dependency_overrides` 属性,该属性就是**字典**。 要在测试时覆盖原有依赖项,这个字典的键应当是原依赖项(函数),值是覆盖依赖项(另一个函数)。 这样一来,**FastAPI** 就会调用覆盖依赖项,不再调用原依赖项。 ```Python hl_lines="26-27 30"
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 1.9K bytes - Viewed (0) -
docs/pt/docs/advanced/testing-dependencies.md
### Utilize o atributo `app.dependency_overrides` Para estes casos, a sua aplicação **FastAPI** possui o atributo `app.dependency_overrides`. Ele é um simples `dict`.
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 3.2K bytes - Viewed (0) -
docs_src/settings/app02_an/test_main.py
from .config import Settings from .main import app, get_settings client = TestClient(app) def get_settings_override(): return Settings(admin_email="******@****.***") app.dependency_overrides[get_settings] = get_settings_override def test_app(): response = client.get("/info") data = response.json() assert data == { "app_name": "Awesome API",
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 515 bytes - Viewed (0) -
docs_src/settings/app02_an_py39/test_main.py
from .config import Settings from .main import app, get_settings client = TestClient(app) def get_settings_override(): return Settings(admin_email="******@****.***") app.dependency_overrides[get_settings] = get_settings_override def test_app(): response = client.get("/info") data = response.json() assert data == { "app_name": "Awesome API",
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 515 bytes - Viewed (0) -
docs_src/dependency_testing/tutorial001_an_py39.py
return {"message": "Hello Users!", "params": commons} client = TestClient(app) async def override_dependency(q: Union[str, None] = None): return {"q": q, "skip": 5, "limit": 10} app.dependency_overrides[common_parameters] = override_dependency def test_override_in_items(): response = client.get("/items/") assert response.status_code == 200 assert response.json() == {
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 1.5K bytes - Viewed (0) -
docs/en/docs/reference/fastapi.md
```python from fastapi import FastAPI ``` ::: fastapi.FastAPI options: members: - openapi_version - webhooks - state - dependency_overrides - openapi - websocket - include_router - get - put - post - delete - options - head
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Apr 18 19:53:19 UTC 2024 - 701 bytes - Viewed (0)