mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-11-22 13:29:19 +08:00
test(copilot): use the real httpx in the hooks test instead of a partial stub
Review on #3968 (JerrettDavis): run alone, the file failed 2 of 3. The partial httpx stub was in sys.modules when a cold import of headroom.ccr pulled in MCP's SSE client, which needs httpx.Response. httpx is a core dependency, so the stub is dropped and the real module is used. That also keeps the TransportError hierarchy the proxy catches exactly as shipped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
66eff96f2a
commit
f419f5333e
@@ -13,7 +13,6 @@ ROOT = Path(__file__).resolve().parents[1]
|
||||
_ISOLATED_MODULE_NAMES = (
|
||||
"headroom.proxy",
|
||||
"headroom.proxy.handlers",
|
||||
"httpx",
|
||||
"fastapi.responses",
|
||||
"tests.headroom_proxy_handlers_openai",
|
||||
"tests.headroom_proxy_handlers_streaming",
|
||||
@@ -42,14 +41,10 @@ def _load_handler_module(monkeypatch: pytest.MonkeyPatch, module_name: str, rela
|
||||
handlers_pkg.__path__ = [str(ROOT / "headroom" / "proxy" / "handlers")]
|
||||
monkeypatch.setitem(sys.modules, "headroom.proxy.handlers", handlers_pkg)
|
||||
|
||||
httpx_mod = types.ModuleType("httpx")
|
||||
# Mirror httpx's hierarchy: proxy code catches the TransportError base.
|
||||
httpx_mod.TransportError = type("TransportError", (Exception,), {})
|
||||
httpx_mod.ConnectError = type("ConnectError", (httpx_mod.TransportError,), {})
|
||||
httpx_mod.ConnectTimeout = type("ConnectTimeout", (httpx_mod.TransportError,), {})
|
||||
httpx_mod.PoolTimeout = type("PoolTimeout", (httpx_mod.TransportError,), {})
|
||||
httpx_mod.ReadTimeout = type("ReadTimeout", (httpx_mod.TransportError,), {})
|
||||
monkeypatch.setitem(sys.modules, "httpx", httpx_mod)
|
||||
# The real httpx, not a stub: it is a core dependency, and a partial stub
|
||||
# breaks whatever else imports httpx during a cold import (the CCR/MCP SSE
|
||||
# client needs httpx.Response). It also keeps the exception hierarchy the
|
||||
# proxy catches (TransportError and its subclasses) exactly as in production.
|
||||
|
||||
responses_mod = types.ModuleType("fastapi.responses")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user