2024-02-29 10:16:42 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2021-06-28 20:36:13 +00:00
|
|
|
import functools
|
2024-07-27 09:31:16 +00:00
|
|
|
from typing import Any, Literal
|
2021-06-19 17:02:53 +00:00
|
|
|
|
2021-06-18 14:48:43 +00:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from starlette.testclient import TestClient
|
2024-07-27 09:31:16 +00:00
|
|
|
from tests.types import TestClientFactory
|
2024-02-04 17:13:09 +00:00
|
|
|
|
2021-06-18 14:48:43 +00:00
|
|
|
|
|
|
|
@pytest.fixture
|
2024-02-04 17:13:09 +00:00
|
|
|
def test_client_factory(
|
2024-02-09 08:58:52 +00:00
|
|
|
anyio_backend_name: Literal["asyncio", "trio"],
|
2024-02-29 10:16:42 +00:00
|
|
|
anyio_backend_options: dict[str, Any],
|
2024-02-04 17:13:09 +00:00
|
|
|
) -> TestClientFactory:
|
2021-06-28 20:36:13 +00:00
|
|
|
# anyio_backend_name defined by:
|
|
|
|
# https://anyio.readthedocs.io/en/stable/testing.html#specifying-the-backends-to-run-on
|
|
|
|
return functools.partial(
|
|
|
|
TestClient,
|
|
|
|
backend=anyio_backend_name,
|
|
|
|
backend_options=anyio_backend_options,
|
|
|
|
)
|