Search Options

Results per page
Sort
Preferred Languages
Advance

Results 101 - 110 of 518 for testclient (0.07 sec)

  1. 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)
  2. 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)
  3. 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)
  4. 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)
  5. tests/test_tutorial/test_path_operation_advanced_configurations/test_tutorial003.py

    from fastapi.testclient import TestClient
    
    from docs_src.path_operation_advanced_configuration.tutorial003_py39 import app
    
    client = TestClient(app)
    
    
    def test_get():
        response = client.get("/items/")
        assert response.status_code == 200, response.text
        assert response.json() == [{"item_id": "Foo"}]
    
    
    def test_openapi_schema():
        response = client.get("/openapi.json")
        assert response.status_code == 200, response.text
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 580 bytes
    - Viewed (0)
  6. docs/es/docs/advanced/testing-websockets.md

    # Probando WebSockets { #testing-websockets }
    
    Puedes usar el mismo `TestClient` para probar WebSockets.
    
    Para esto, usas el `TestClient` en un statement `with`, conectándote al WebSocket:
    
    {* ../../docs_src/app_testing/tutorial002_py39.py hl[27:31] *}
    
    /// note | Nota
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 477 bytes
    - Viewed (0)
  7. tests/test_tutorial/test_middleware/test_tutorial001.py

    from fastapi.testclient import TestClient
    
    from docs_src.middleware.tutorial001_py39 import app
    
    client = TestClient(app)
    
    
    def test_response_headers():
        response = client.get("/openapi.json")
        assert response.status_code == 200, response.text
        assert "X-Process-Time" in response.headers
    
    
    def test_openapi_schema():
        response = client.get("/openapi.json")
        assert response.status_code == 200, response.text
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Dec 26 10:43:02 UTC 2025
    - 604 bytes
    - Viewed (0)
  8. tests/test_orjson_response_class.py

    from fastapi.responses import ORJSONResponse
    from fastapi.testclient import TestClient
    from sqlalchemy.sql.elements import quoted_name
    
    app = FastAPI(default_response_class=ORJSONResponse)
    
    
    @app.get("/orjson_non_str_keys")
    def get_orjson_non_str_keys():
        key = quoted_name(value="msg", quote=False)
        return {key: "Hello World", 1: 1}
    
    
    client = TestClient(app)
    
    
    def test_orjson_non_str_keys():
        with client:
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Sep 02 10:17:31 UTC 2022
    - 562 bytes
    - Viewed (0)
  9. tests/test_request_params/test_header/test_optional_str.py

    from typing import Annotated, Optional
    
    import pytest
    from fastapi import FastAPI, Header
    from fastapi.testclient import TestClient
    from pydantic import BaseModel, Field
    
    app = FastAPI()
    
    # =====================================================================================
    # Without aliases
    
    
    @app.get("/optional-str")
    async def read_optional_str(p: Annotated[Optional[str], Header()] = None):
        return {"p": p}
    
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 8.2K bytes
    - Viewed (0)
  10. tests/test_dependency_contextvars.py

    from collections.abc import Awaitable
    from contextvars import ContextVar
    from typing import Any, Callable, Optional
    
    from fastapi import Depends, FastAPI, Request, Response
    from fastapi.testclient import TestClient
    
    legacy_request_state_context_var: ContextVar[Optional[dict[str, Any]]] = ContextVar(
        "legacy_request_state_context_var", default=None
    )
    
    app = FastAPI()
    
    
    async def set_up_request_state_dependency():
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 1.5K bytes
    - Viewed (0)
Back to top