Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 7 of 7 for Reset (0.16 sec)

  1. docs/en/docs/how-to/sql-databases-peewee.md

    So, you would reset it with:
    
    ```Python hl_lines="3-4"
    async def reset_db_state():
        database.db.obj._state._state.set(db_state_default.copy())
        database.db.obj._state.reset()
    ```
    
    ### Create your **FastAPI** *path operations*
    
    Now, finally, here's the standard **FastAPI** *path operations* code.
    
    Plain Text
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Tue Jan 16 13:23:25 GMT 2024
    - 23.6K bytes
    - Viewed (0)
  2. docs_src/sql_databases_peewee/sql_app/main.py

    database.db.connect()
    database.db.create_tables([models.User, models.Item])
    database.db.close()
    
    app = FastAPI()
    
    sleep_time = 10
    
    
    async def reset_db_state():
        database.db._state._state.set(db_state_default.copy())
        database.db._state.reset()
    
    
    def get_db(db_state=Depends(reset_db_state)):
        try:
            database.db.connect()
            yield
        finally:
            if not database.db.is_closed():
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 2.2K bytes
    - Viewed (0)
  3. tests/test_dependency_normal_exceptions.py

    
    @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)
    def reset_state_and_db():
        global fake_database
        global state
        fake_database = initial_fake_database.copy()
        state = initial_state.copy()
    
    
    client = TestClient(app)
    
    
    def test_dependency_gets_exception():
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sat Feb 24 23:06:37 GMT 2024
    - 1.9K bytes
    - Viewed (0)
  4. tests/test_dependency_contextvars.py

    async def set_up_request_state_dependency():
        request_state = {"user": "deadpond"}
        contextvar_token = legacy_request_state_context_var.set(request_state)
        yield request_state
        legacy_request_state_context_var.reset(contextvar_token)
    
    
    @app.middleware("http")
    async def custom_middleware(
        request: Request, call_next: Callable[[Request], Awaitable[Response]]
    ):
        response = await call_next(request)
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Feb 17 12:40:12 GMT 2022
    - 1.5K bytes
    - Viewed (0)
  5. docs/em/docs/how-to/sql-databases-peewee.md

    ```Python
    # db._state = PeeweeConnectionState()
    ```
    
    & ๐Ÿ“ `sql_app/main.py` ๐Ÿ“, ๐Ÿค ๐Ÿ’ช `async` ๐Ÿ”— `reset_db_state()` & โŽ โšซ๏ธ โฎ๏ธ `pass`:
    
    ```Python
    async def reset_db_state():
    #     database.db._state._state.set(db_state_default.copy())
    #     database.db._state.reset()
        pass
    ```
    
    โคด๏ธ ๐Ÿƒ ๐Ÿ‘† ๐Ÿ“ฑ โฎ๏ธ Uvicorn:
    
    <div class="termy">
    
    ```console
    Plain Text
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 19.2K bytes
    - Viewed (0)
  6. docs/en/docs/advanced/testing-dependencies.md

        FastAPI will still be able to override it.
    
    Then you can reset your overrides (remove them) by setting `app.dependency_overrides` to be an empty `dict`:
    
    ```Python
    app.dependency_overrides = {}
    ```
    
    !!! tip
    Plain Text
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Tue Oct 17 05:59:11 GMT 2023
    - 2.9K bytes
    - Viewed (0)
  7. docs/en/docs/release-notes.md

    This means that now, if you set a value in a context variable before `yield`, the value would still be available after `yield` (as you would intuitively expect). And it also means that you can reset the context variable with a token afterwards.
    
    For example, this works correctly now:
    
    ```Python
    from contextvars import ContextVar
    from typing import Any, Dict, Optional
    
    
    Plain Text
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri Apr 19 19:30:49 GMT 2024
    - 384.6K bytes
    - Viewed (1)
Back to top