Search Options

Results per page
Sort
Preferred Languages
Advance

Results 81 - 90 of 509 for testclient (0.04 sec)

  1. tests/test_tutorial/test_security/test_tutorial007.py

    from base64 import b64encode
    
    import pytest
    from fastapi.testclient import TestClient
    
    
    @pytest.fixture(
        name="client",
        params=[
            pytest.param("tutorial007_py39"),
            pytest.param("tutorial007_an_py39"),
        ],
    )
    def get_client(request: pytest.FixtureRequest):
        mod = importlib.import_module(f"docs_src.security.{request.param}")
        return TestClient(mod.app)
    
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Dec 26 10:43:02 UTC 2025
    - 3.2K bytes
    - Viewed (0)
  2. tests/test_tutorial/test_path_params_numeric_validations/test_tutorial006.py

    import pytest
    from fastapi.testclient import TestClient
    
    
    @pytest.fixture(
        name="client",
        params=[
            pytest.param("tutorial006_py39"),
            pytest.param("tutorial006_an_py39"),
        ],
    )
    def get_client(request: pytest.FixtureRequest) -> TestClient:
        mod = importlib.import_module(
            f"docs_src.path_params_numeric_validations.{request.param}"
        )
        return TestClient(mod.app)
    
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Dec 26 10:43:02 UTC 2025
    - 7.3K bytes
    - Viewed (0)
  3. tests/test_ws_router.py

    import pytest
    from fastapi import (
        APIRouter,
        Depends,
        FastAPI,
        Header,
        WebSocket,
        WebSocketDisconnect,
        status,
    )
    from fastapi.middleware import Middleware
    from fastapi.testclient import TestClient
    
    router = APIRouter()
    prefix_router = APIRouter()
    native_prefix_route = APIRouter(prefix="/native")
    app = FastAPI()
    
    
    @app.websocket_route("/")
    async def index(websocket: WebSocket):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sun Jun 11 19:08:14 UTC 2023
    - 7.5K bytes
    - Viewed (0)
  4. tests/test_forms_from_non_typing_sequences.py

    from fastapi.testclient import TestClient
    
    app = FastAPI()
    
    
    @app.post("/form/python-list")
    def post_form_param_list(items: list = Form()):
        return items
    
    
    @app.post("/form/python-set")
    def post_form_param_set(items: set = Form()):
        return items
    
    
    @app.post("/form/python-tuple")
    def post_form_param_tuple(items: tuple = Form()):
        return items
    
    
    client = TestClient(app)
    
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri May 13 23:38:22 UTC 2022
    - 1.2K bytes
    - Viewed (0)
  5. docs/en/docs/advanced/async-tests.md

    The `TestClient` does some magic inside to call the asynchronous FastAPI application in your normal `def` test functions, using standard pytest. But that magic doesn't work anymore when we're using it inside asynchronous functions. By running our tests asynchronously, we can no longer use the `TestClient` inside our test functions.
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 4K bytes
    - Viewed (0)
  6. tests/test_request_params/test_file/test_optional.py

    from typing import Annotated, Optional
    
    import pytest
    from fastapi import FastAPI, File, UploadFile
    from fastapi.testclient import TestClient
    
    from .utils import get_body_model_name
    
    app = FastAPI()
    
    # =====================================================================================
    # Without aliases
    
    
    @app.post("/optional-bytes", operation_id="optional_bytes")
    async def read_optional_bytes(p: Annotated[Optional[bytes], File()] = None):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 9.7K bytes
    - Viewed (0)
  7. tests/test_request_params/test_form/test_optional_str.py

    from typing import Annotated, Optional
    
    import pytest
    from fastapi import FastAPI, Form
    from fastapi.testclient import TestClient
    from pydantic import BaseModel, Field
    
    from .utils import get_body_model_name
    
    app = FastAPI()
    
    # =====================================================================================
    # Without aliases
    
    
    @app.post("/optional-str", operation_id="optional_str")
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 8.9K bytes
    - Viewed (0)
  8. tests/test_request_params/test_query/test_optional_list.py

    from typing import Annotated, Optional
    
    import pytest
    from fastapi import FastAPI, Query
    from fastapi.testclient import TestClient
    from pydantic import BaseModel, Field
    
    app = FastAPI()
    
    # =====================================================================================
    # Without aliases
    
    
    @app.get("/optional-list-str")
    async def read_optional_list_str(
        p: Annotated[Optional[list[str]], Query()] = None,
    ):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 9.1K bytes
    - Viewed (0)
  9. tests/test_request_params/test_query/test_required_str.py

    from typing import Annotated
    
    import pytest
    from dirty_equals import IsOneOf
    from fastapi import FastAPI, Query
    from fastapi.testclient import TestClient
    from pydantic import BaseModel, Field
    
    app = FastAPI()
    
    # =====================================================================================
    # Without aliases
    
    
    @app.get("/required-str")
    async def read_required_str(p: str):
        return {"p": p}
    
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 9.9K bytes
    - Viewed (0)
  10. tests/test_dependency_security_overrides.py

    from fastapi import Depends, FastAPI, Security
    from fastapi.security import SecurityScopes
    from fastapi.testclient import TestClient
    
    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():
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 1.4K bytes
    - Viewed (1)
Back to top