import math
import sys
import typing
+import warnings
from concurrent.futures import Future
from types import GeneratorType
from urllib.parse import unquote, urljoin
timeout: httpx._types.TimeoutTypes | httpx._client.UseClientDefault = httpx._client.USE_CLIENT_DEFAULT,
extensions: dict[str, typing.Any] | None = None,
) -> httpx.Response:
+ if timeout is not httpx.USE_CLIENT_DEFAULT:
+ warnings.warn(
+ "You should not use the 'timeout' argument with the TestClient. "
+ "See https://github.com/encode/starlette/issues/1108 for more information.",
+ DeprecationWarning,
+ )
url = self._merge_url(url)
return super().request(
method,
with client.websocket_connect("/hello-world", params={"foo": "bar"}) as websocket:
data = websocket.receive_bytes()
assert data == b"/hello-world"
+
+
+def test_timeout_deprecation() -> None:
+ with pytest.deprecated_call(match="You should not use the 'timeout' argument with the TestClient."):
+ client = TestClient(mock_service)
+ client.get("/", timeout=1)