Skip to content

Commit a9bb8a6

Browse files
committed
fix: stabilize OpenAI HTTP client test
1 parent 889feb9 commit a9bb8a6

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

tests/test_openai_source.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ def _make_groq_provider(overrides: dict | None = None) -> ProviderGroq:
6262

6363
def test_create_http_client_uses_openai_httpx_module(monkeypatch):
6464
captured: dict[str, object] = {}
65+
fake_httpx_module = object()
66+
67+
from openai import _base_client as openai_base_client
68+
69+
monkeypatch.setattr(
70+
openai_base_client,
71+
"httpx",
72+
fake_httpx_module,
73+
raising=False,
74+
)
6575

6676
def fake_create_proxy_client(
6777
provider_label: str,
@@ -82,9 +92,7 @@ def fake_create_proxy_client(
8292
provider = ProviderOpenAIOfficial.__new__(ProviderOpenAIOfficial)
8393
provider._create_http_client({"proxy": ""})
8494

85-
from openai import _base_client as openai_base_client
86-
87-
assert captured["httpx_module"] is openai_base_client.httpx
95+
assert captured["httpx_module"] is fake_httpx_module
8896

8997

9098
def test_create_http_client_falls_back_to_global_httpx_module(monkeypatch):

0 commit comments

Comments
 (0)