Files
hermes-agent/tests/gateway/test_api_server_runs_import_isolation.py
T
teknium1 21bc1d3775 fix(api-server): trim RequestKey fallback comment, add import-isolation test
The salvaged comment restated the symptom at length; keep only the WHY.
Drop the `# pragma: no cover` markers (the repo does not gate on coverage).
One invariant test: with aiohttp.web_request lacking RequestKey, `web` stays
bound to the aiohttp module and RequestKey is None (red on origin/main).
2026-09-12 08:04:30 -07:00

26 lines
769 B
Python

"""Import-time invariant: a missing ``RequestKey`` must not take ``web`` down with it."""
import importlib
import sys
import types
import aiohttp.web_request
from aiohttp import web
def test_missing_requestkey_keeps_web_module_bound():
import gateway.platforms.api_server_runs as api_server_runs
stub = types.ModuleType("aiohttp.web_request")
real = sys.modules["aiohttp.web_request"]
sys.modules["aiohttp.web_request"] = stub
try:
importlib.reload(api_server_runs)
assert api_server_runs.web is web
assert api_server_runs.RequestKey is None
finally:
sys.modules["aiohttp.web_request"] = real
importlib.reload(api_server_runs)
assert api_server_runs.RequestKey is aiohttp.web_request.RequestKey