From ea22067c52ec335ea4d3a616cb2107d5fdbdf7b6 Mon Sep 17 00:00:00 2001 From: blasty Date: Fri, 21 Aug 2026 12:12:53 +0200 Subject: tests: repair the two seams the ida-nexus port left behind Two scenario monkeypatch sites still hooked client.invoke -- the rename to call() updated the call sites but not the patches, so reprime_is_free and split_view crashed instead of counting. call() takes the remote_ops declaration itself now, so both count by its __name__. remote_ops imported RemoteModule inside _bindings(), which made test_nexus_client (NEEDS_IDA = False) unrunnable under a stdlib-only python3 -- the house rule tests/run.py --fast depends on. The import moves to the same eagerly-if-present, bound-to-None-so-patchable contract nexus_client uses, and the test injects FakeRemoteModule/FakeRemoteError exactly like its other fakes: real names when the library is installed, strict fakes when it is not. --- idatui/remote_ops.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'idatui/remote_ops.py') diff --git a/idatui/remote_ops.py b/idatui/remote_ops.py index a67b2b7..cbd1d49 100644 --- a/idatui/remote_ops.py +++ b/idatui/remote_ops.py @@ -11,6 +11,16 @@ from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from ida_domain import Database +# Same contract as nexus_client: ida_nexus is imported eagerly-if-present but +# never at hard import cost, and the name is bound to None rather than left +# undefined so it stays PATCHABLE -- the offline contract tests inject a fake +# RemoteModule here and run this module's binding logic under a stdlib-only +# python3 (tests/run.py --fast). +try: + from ida_nexus import RemoteModule +except ImportError: # library absent: bindings fail actionably on first use + RemoteModule = None # type: ignore[assignment,misc] + def operation_label() -> str: """Display attribution for the current call; ready for per-user context.""" @@ -1655,8 +1665,13 @@ def _bindings() -> dict[Callable[..., Any], Any]: with _BIND_LOCK: if _BOUND is not None: return _BOUND - from ida_nexus import RemoteModule - + # Gated on the binding, not a fresh import, so an injected fake is + # honoured (see the module docstring on the guarded import above). + if RemoteModule is None: + raise ImportError( + "The 'ida-nexus' package is required to execute remote " + "operations but is not installed in this interpreter." + ) operations_module = RemoteModule( Path(__file__), operation_label=operation_label, codec="json" ) -- cgit v1.3.1-sl0p