Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

test(cli): import scipy.sparse before the real-call guard so its CPU probe is not refused (#4024)

Raghav Chamadiyabea064e48e67
diff --git a/tests/unit/cli/_real_call_guard.py b/tests/unit/cli/_real_call_guard.py
index 34ea30279..b37e15286 100644
--- a/tests/unit/cli/_real_call_guard.py
+++ b/tests/unit/cli/_real_call_guard.py
@@ -8,6 +8,7 @@ guard, since its monkeypatch runs after this one.
from __future__ import annotations
+import contextlib
import os
import socket
import subprocess
@@ -42,6 +43,10 @@ def guard_real_calls(monkeypatch: pytest.MonkeyPatch, *, allow_git: bool = False
Windows asyncio loop) and the OS-assigned port fallback use, and they
never claim a real port.
"""
+ # The first scipy.sparse import (networkx pagerank) probes the CPU with lscpu on Linux.
+ with contextlib.suppress(ImportError):
+ import scipy.sparse # noqa: F401
+
real_popen_init = subprocess.Popen.__init__
def _popen_init(self, args, *a, **kw):