Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

tests/openai: patch httpx.AsyncClient ctor so delete tests hit mock (#5469)

Daniel Hane775f941a42e
diff --git a/studio/backend/tests/test_openai_container_crud.py b/studio/backend/tests/test_openai_container_crud.py
index fbc03936776..161a6fab83a 100644
--- a/studio/backend/tests/test_openai_container_crud.py
+++ b/studio/backend/tests/test_openai_container_crud.py
@@ -28,8 +28,20 @@ def _drive(coro):
def _mock_http_client(monkeypatch, handler):
+ """Wire `handler` for both the shared `_http_client` AND any
+ per-call `httpx.AsyncClient(...)` instances. delete_openai_container
+ intentionally creates a fresh AsyncClient (see comment in
+ external_provider.delete_openai_container) so the test must
+ also intercept that constructor."""
transport = httpx.MockTransport(handler)
monkeypatch.setattr(ep_mod, "_http_client", httpx.AsyncClient(transport = transport))
+ real_async_client = httpx.AsyncClient
+
+ def _patched_async_client(*args, **kwargs):
+ kwargs["transport"] = transport
+ return real_async_client(*args, **kwargs)
+
+ monkeypatch.setattr(ep_mod.httpx, "AsyncClient", _patched_async_client)
def _make_client() -> ExternalProviderClient: