Skip to content

The agent that grows with you

test(tools): keep mocked SDK paths off the real lazy-dep gate

liuhao1024551bd46a79ab
diff --git a/tests/tools/test_image_generation.py b/tests/tools/test_image_generation.py
index bf9c808ec70..ddc6bfd556a 100644
--- a/tests/tools/test_image_generation.py
+++ b/tests/tools/test_image_generation.py
@@ -466,6 +466,13 @@ class TestExtractHttpStatus:
class TestManagedGatewayErrorTranslation:
"""4xx from the Nous managed gateway should be translated to a user-actionable message."""
+ @pytest.fixture(autouse=True)
+ def _fal_client_stub(self, image_tool, monkeypatch):
+ # These tests drive a mocked managed client; the module-global loader
+ # must not demand the optional fal extra (a version-pinned metadata
+ # check under lazy installs) on the way there.
+ monkeypatch.setattr(image_tool, "fal_client", object())
+
def test_4xx_translates_to_value_error_with_remediation(self, image_tool, monkeypatch):
"""403 from managed gateway → ValueError mentioning FAL_KEY + hermes tools."""
from unittest.mock import MagicMock
diff --git a/tests/tools/test_managed_media_gateways.py b/tests/tools/test_managed_media_gateways.py
index ffac787550f..46a4b5b1b2a 100644
--- a/tests/tools/test_managed_media_gateways.py
+++ b/tests/tools/test_managed_media_gateways.py
@@ -185,6 +185,16 @@ def test_managed_fal_submit_uses_gateway_origin_and_nous_token(monkeypatch):
captured = {}
_install_fake_tools_package()
_install_fake_fal_client(captured)
+ # The fake fal_client above answers every SDK touch; the real lazy-dep gate
+ # (a version-pinned metadata check) must not refuse first on an install
+ # without the fal extra. Replace the sys.modules entry itself so the
+ # loader's ``from tools.lazy_deps import ensure`` resolves to the stub no
+ # matter which tools package object a prior test left behind.
+ monkeypatch.setitem(
+ sys.modules,
+ "tools.lazy_deps",
+ types.SimpleNamespace(ensure=lambda *args, **kwargs: None),
+ )
monkeypatch.delenv("FAL_KEY", raising=False)
monkeypatch.setenv("FAL_QUEUE_GATEWAY_URL", "http://127.0.0.1:3009")
monkeypatch.setenv("TOOL_GATEWAY_USER_TOKEN", "nous-token")
diff --git a/tests/tools/test_modal_snapshot_isolation.py b/tests/tools/test_modal_snapshot_isolation.py
index 2f7911b385e..be3a710c143 100644
--- a/tests/tools/test_modal_snapshot_isolation.py
+++ b/tests/tools/test_modal_snapshot_isolation.py
@@ -76,6 +76,13 @@ def _install_modal_test_modules(
env_package.__path__ = [str(TOOLS_DIR / "environments")] # type: ignore[attr-defined]
sys.modules["tools.environments"] = env_package
+ # The faked modal module below answers every SDK touch; the real lazy-dep
+ # gate (a version-pinned metadata check) must not refuse first on an
+ # install without the modal extra.
+ sys.modules["tools.lazy_deps"] = types.SimpleNamespace(
+ ensure=lambda *args, **kwargs: None
+ )
+
class _DummyBaseEnvironment:
def __init__(self, cwd: str, timeout: int, env=None):
self.cwd = cwd
diff --git a/tests/tools/test_web_tools_config.py b/tests/tools/test_web_tools_config.py
index fdad7a0853f..3737c78bc83 100644
--- a/tests/tools/test_web_tools_config.py
+++ b/tests/tools/test_web_tools_config.py
@@ -402,12 +402,20 @@ class TestParallelClientConfig:
fake_parallel.Parallel = Parallel
fake_parallel.AsyncParallel = AsyncParallel
sys.modules["parallel"] = fake_parallel
+ # The fake parallel module above answers every SDK touch; the real
+ # lazy-dep gate (a version-pinned metadata check) must not refuse first
+ # on an install without the parallel extra.
+ self._lazy_gate_patch = patch(
+ "tools.lazy_deps.ensure", lambda *args, **kwargs: None
+ )
+ self._lazy_gate_patch.start()
def teardown_method(self):
import tools.web_tools
tools.web_tools._parallel_client = None
os.environ.pop("PARALLEL_API_KEY", None)
sys.modules.pop("parallel", None)
+ self._lazy_gate_patch.stop()
def test_creates_client_with_key(self):
"""PARALLEL_API_KEY set → creates Parallel client."""