Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 4 of 4 for dependency (0.21 sec)

  1. 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`.
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Tue Oct 17 05:59:11 GMT 2023
    - 2.9K bytes
    - Viewed (0)
  2. docs/de/docs/advanced/testing-dependencies.md

        ```Python hl_lines="26-27  30"
        {!> ../../../docs_src/dependency_testing/tutorial001_an_py310.py!}
        ```
    
    === "Python 3.9+"
    
        ```Python hl_lines="28-29  32"
        {!> ../../../docs_src/dependency_testing/tutorial001_an_py39.py!}
        ```
    
    === "Python 3.8+"
    
        ```Python hl_lines="29-30  33"
        {!> ../../../docs_src/dependency_testing/tutorial001_an.py!}
        ```
    
    === "Python 3.10+ nicht annotiert"
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Mar 30 20:17:32 GMT 2024
    - 3.6K bytes
    - Viewed (0)
  3. docs/zh/docs/advanced/testing-dependencies.md

    一般只要测试一次外部验证应用就够了,不必每次测试都去调用。
    
    此时,最好覆盖调用外部验证应用的依赖项,使用返回模拟测试用户的自定义依赖项就可以了。
    
    ### 使用 `app.dependency_overrides` 属性
    
    对于这些用例,**FastAPI** 应用支持 `app.dependcy_overrides` 属性,该属性就是**字典**。
    
    要在测试时覆盖原有依赖项,这个字典的键应当是原依赖项(函数),值是覆盖依赖项(另一个函数)。
    
    这样一来,**FastAPI** 就会调用覆盖依赖项,不再调用原依赖项。
    
    ```Python hl_lines="26-27  30"
    {!../../../docs_src/dependency_testing/tutorial001.py!}
    ```
    
    !!! tip "提示"
    
        **FastAPI** 应用中的任何位置都可以实现覆盖依赖项。
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Mar 30 22:45:53 GMT 2024
    - 1.9K bytes
    - Viewed (0)
  4. docs/em/docs/advanced/testing-dependencies.md

    👉 💼, 👆 💪 🔐 🔗 👈 🤙 👈 🐕‍🦺, & ⚙️ 🛃 🔗 👈 📨 🎁 👩‍💻, 🕴 👆 💯.
    
    ### ⚙️ `app.dependency_overrides` 🔢
    
    👫 💼, 👆 **FastAPI** 🈸 ✔️ 🔢 `app.dependency_overrides`, ⚫️ 🙅 `dict`.
    
    🔐 🔗 🔬, 👆 🚮 🔑 ⏮️ 🔗 (🔢), & 💲, 👆 🔗 🔐 (➕1️⃣ 🔢).
    
    & ⤴️ **FastAPI** 🔜 🤙 👈 🔐 ↩️ ⏮️ 🔗.
    
    ```Python hl_lines="28-29  32"
    {!../../../docs_src/dependency_testing/tutorial001.py!}
    ```
    
    !!! tip
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Apr 01 09:26:04 GMT 2023
    - 1.8K bytes
    - Viewed (0)
Back to top