Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 51 - 60 of 1,458 for BytesX (0.05 seconds)

  1. tests/test_ambiguous_params.py

    from typing import Annotated
    
    import pytest
    from fastapi import Depends, FastAPI, Path
    from fastapi.param_functions import Query
    from fastapi.testclient import TestClient
    
    app = FastAPI()
    
    
    def test_no_annotated_defaults():
        with pytest.raises(
            AssertionError, match="Path parameters cannot have a default value"
        ):
    
            @app.get("/items/{item_id}/")
            async def get_item(item_id: Annotated[int, Path(default=1)]):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sat Dec 20 15:55:38 GMT 2025
    - 2K bytes
    - Click Count (1)
  2. tests/test_computed_fields.py

        client = TestClient(app)
        return client
    
    
    @pytest.mark.parametrize("client", [True, False], indirect=True)
    @pytest.mark.parametrize("path", ["/", "/responses"])
    def test_get(client: TestClient, path: str):
        response = client.get(path)
        assert response.status_code == 200, response.text
        assert response.json() == {"width": 3, "length": 4, "area": 12}
    
    
    @pytest.mark.parametrize("client", [True, False], indirect=True)
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Feb 08 10:18:38 GMT 2026
    - 3.8K bytes
    - Click Count (0)
  3. tests/test_request_params/test_query/test_list.py

    from typing import Annotated
    
    import pytest
    from dirty_equals import IsOneOf
    from fastapi import FastAPI, Query
    from fastapi.testclient import TestClient
    from inline_snapshot import snapshot
    from pydantic import BaseModel, Field
    
    app = FastAPI()
    
    # =====================================================================================
    # Without aliases
    
    
    @app.get("/required-list-str")
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Feb 08 10:18:38 GMT 2026
    - 11.2K bytes
    - Click Count (0)
  4. tests/test_response_model_invalid.py

    import pytest
    from fastapi import FastAPI
    from fastapi.exceptions import FastAPIError
    
    
    class NonPydanticModel:
        pass
    
    
    def test_invalid_response_model_raises():
        with pytest.raises(FastAPIError):
            app = FastAPI()
    
            @app.get("/", response_model=NonPydanticModel)
            def read_root():
                pass  # pragma: nocover
    
    
    def test_invalid_response_model_sub_type_raises():
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Dec 17 21:25:59 GMT 2025
    - 1.1K bytes
    - Click Count (0)
  5. tests/test_allow_inf_nan_in_enforcing.py

    
    @pytest.mark.parametrize(
        "value,code",
        [
            ("-1", 200),
            ("inf", 200),
            ("-inf", 200),
            ("nan", 200),
            ("0", 200),
            ("342", 200),
        ],
    )
    def test_allow_inf_nan_param_true(value: str, code: int):
        response = client.post(f"/?x={value}")
        assert response.status_code == code, response.text
    
    
    @pytest.mark.parametrize(
        "value,code",
        [
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Dec 17 21:25:59 GMT 2025
    - 1.8K bytes
    - Click Count (0)
  6. tests/test_invalid_sequence_param.py

    import pytest
    from fastapi import FastAPI, Query
    from pydantic import BaseModel
    
    
    def test_invalid_sequence():
        with pytest.raises(
            AssertionError,
            match="Query parameter 'q' must be one of the supported types",
        ):
            app = FastAPI()
    
            class Item(BaseModel):
                title: str
    
            @app.get("/items/")
            def read_items(q: list[Item] = Query(default=None)):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Tue Feb 17 09:59:14 GMT 2026
    - 1.5K bytes
    - Click Count (0)
  7. docs/ru/docs/advanced/async-tests.md

    ## Запуск тестов { #run-it }
    
    Вы можете запустить свои тесты как обычно:
    
    <div class="termy">
    
    ```console
    $ pytest
    
    ---> 100%
    ```
    
    </div>
    
    ## Подробнее { #in-detail }
    
    Маркер `@pytest.mark.anyio` говорит pytest, что тестовая функция должна быть вызвана асинхронно:
    
    {* ../../docs_src/async_tests/app_a_py310/test_main.py hl[7] *}
    
    /// tip | Подсказка
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 19 17:56:20 GMT 2026
    - 6.2K bytes
    - Click Count (0)
  8. tests/test_schema_extra_examples.py

        ):
            return item_id
    
        with pytest.warns(FastAPIDeprecationWarning):
    
            @app.get("/path_example_examples/{item_id}")
            def path_example_examples(
                item_id: str = Path(
                    example="item_overridden",
                    examples=["item_1", "item_2"],
                ),
            ):
                return item_id
    
        with pytest.warns(FastAPIDeprecationWarning):
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Tue Feb 17 09:59:14 GMT 2026
    - 34.7K bytes
    - Click Count (0)
  9. tests/test_dependency_contextmanager.py

        assert state["/async_raise"] == "asyncgen raise not started"
        with pytest.raises(OtherDependencyError):
            client.get("/async_raise_other")
        assert state["/async_raise"] == "asyncgen raise finalized"
        assert "/async_raise" not in errors
    
    
    def test_sync_raise_other():
        assert state["/sync_raise"] == "generator raise not started"
        with pytest.raises(OtherDependencyError):
            client.get("/sync_raise_other")
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Dec 17 21:25:59 GMT 2025
    - 11.5K bytes
    - Click Count (0)
  10. docs/zh-hant/docs/tutorial/testing.md

    建立一個 `TestClient`,把你的 **FastAPI** 應用傳入其中。
    
    建立名稱以 `test_` 開頭的函式(這是 `pytest` 的慣例)。
    
    像使用 `httpx` 一樣使用 `TestClient` 物件。
    
    用簡單的 `assert` 敘述搭配標準的 Python 運算式來檢查(同樣是 `pytest` 的標準用法)。
    
    {* ../../docs_src/app_testing/tutorial001_py310.py hl[2,12,15:18] *}
    
    /// tip
    
    注意測試函式是一般的 `def`,不是 `async def`。
    
    而且對 client 的呼叫也都是一般呼叫,不需要使用 `await`。
    
    這讓你可以直接使用 `pytest`,不必費心處理非同步。
    
    ///
    
    /// note | 技術細節
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:05:38 GMT 2026
    - 5.6K bytes
    - Click Count (0)
Back to Top