Search Options

Results per page
Sort
Preferred Languages
Advance

Results 121 - 130 of 518 for testclient (0.05 sec)

  1. tests/test_request_params/test_header/test_required_str.py

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

    from datetime import datetime, timezone
    
    from fastapi import FastAPI
    from fastapi.testclient import TestClient
    from pydantic import BaseModel
    
    
    def test_pydanticv2():
        from pydantic import field_serializer
    
        class ModelWithDatetimeField(BaseModel):
            dt_field: datetime
    
            @field_serializer("dt_field")
            def serialize_datetime(self, dt_field: datetime):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 12:54:56 UTC 2025
    - 817 bytes
    - Viewed (0)
  3. tests/test_request_params/test_file/test_list.py

    from typing import Annotated
    
    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("/list-bytes", operation_id="list_bytes")
    async def read_list_bytes(p: Annotated[list[bytes], File()]):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:31:34 UTC 2025
    - 11.2K bytes
    - Viewed (0)
  4. tests/test_tutorial/test_path_operation_advanced_configurations/test_tutorial007.py

    import importlib
    
    import pytest
    from fastapi.testclient import TestClient
    
    
    @pytest.fixture(
        name="client",
        params=[
            pytest.param("tutorial007_py39"),
        ],
    )
    def get_client(request: pytest.FixtureRequest):
        mod = importlib.import_module(
            f"docs_src.path_operation_advanced_configuration.{request.param}"
        )
    
        client = TestClient(mod.app)
        return client
    
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 20 15:55:38 UTC 2025
    - 3.4K bytes
    - Viewed (0)
  5. tests/test_tutorial/test_graphql/test_tutorial001.py

    import pytest
    from starlette.testclient import TestClient
    
    warnings.filterwarnings(
        "ignore",
        message=r"The 'lia' package has been renamed to 'cross_web'\..*",
        category=DeprecationWarning,
    )
    
    from docs_src.graphql_.tutorial001_py39 import app  # noqa: E402
    
    
    @pytest.fixture(name="client")
    def get_client() -> TestClient:
        return TestClient(app)
    
    
    def test_query(client: TestClient):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Dec 26 10:43:02 UTC 2025
    - 2.2K bytes
    - Viewed (0)
  6. tests/test_query_cookie_header_model_extra_params.py

    from fastapi import Cookie, FastAPI, Header, Query
    from fastapi.testclient import TestClient
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Model(BaseModel):
        param: str
    
        model_config = {"extra": "allow"}
    
    
    @app.get("/query")
    async def query_model_with_extra(data: Model = Query()):
        return data
    
    
    @app.get("/header")
    async def header_model_with_extra(data: Model = Header()):
        return data
    
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 20 15:55:38 UTC 2025
    - 2.3K bytes
    - Viewed (0)
  7. tests/test_tutorial/test_header_params/test_tutorial001.py

        client = TestClient(mod.app)
        return client
    
    
    @pytest.mark.parametrize(
        "path,headers,expected_status,expected_response",
        [
            ("/items", None, 200, {"User-Agent": "testclient"}),
            ("/items", {"X-Header": "notvalid"}, 200, {"User-Agent": "testclient"}),
            ("/items", {"User-Agent": "FastAPI test"}, 200, {"User-Agent": "FastAPI test"}),
        ],
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 3.9K bytes
    - Viewed (0)
  8. docs_src/dependency_testing/tutorial001_an_py310.py

    from typing import Annotated
    
    from fastapi import Depends, FastAPI
    from fastapi.testclient import TestClient
    
    app = FastAPI()
    
    
    async def common_parameters(q: str | None = None, skip: int = 0, limit: int = 100):
        return {"q": q, "skip": skip, "limit": limit}
    
    
    @app.get("/items/")
    async def read_items(commons: Annotated[dict, Depends(common_parameters)]):
        return {"message": "Hello Items!", "params": commons}
    
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 1.5K bytes
    - Viewed (0)
  9. tests/test_security_http_bearer_optional.py

    from typing import Optional
    
    from fastapi import FastAPI, Security
    from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
    from fastapi.testclient import TestClient
    
    app = FastAPI()
    
    security = HTTPBearer(auto_error=False)
    
    
    @app.get("/users/me")
    def read_current_user(
        credentials: Optional[HTTPAuthorizationCredentials] = Security(security),
    ):
        if credentials is None:
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 2.1K bytes
    - Viewed (0)
  10. tests/test_security_oauth2_authorization_code_bearer_description.py

    from typing import Optional
    
    from fastapi import FastAPI, Security
    from fastapi.security import OAuth2AuthorizationCodeBearer
    from fastapi.testclient import TestClient
    
    app = FastAPI()
    
    oauth2_scheme = OAuth2AuthorizationCodeBearer(
        authorizationUrl="authorize",
        tokenUrl="token",
        description="OAuth2 Code Bearer",
        auto_error=True,
    )
    
    
    @app.get("/items/")
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 2.4K bytes
    - Viewed (0)
Back to top