From 414e298f48dc6725b642b1a0bde8733851abd2c3 Mon Sep 17 00:00:00 2001 From: danielhertz1999-bit Date: Sat, 27 Jun 2026 10:47:21 -0400 Subject: [PATCH] tests: fix NameError in daemon_sock / fake_daemon fixtures (macOS CI) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both fixtures referenced `tmp_path` in their body without it being a parameter, so every test using them errored at setup with "NameError: name 'tmp_path' is not defined" — visible on the macOS CI gate (incl. the Release v1.2.0 run) as 5 setup errors across test_mcp_tools.py and test_socket_disconnect_reconnect.py. daemon_sock is also module-scoped, where the function-scoped tmp_path wouldn't be usable regardless. Bind the control socket under a short tempfile.mkdtemp(prefix="iai-sock-") dir instead — which both removes the undefined-name reference and keeps the AF_UNIX path under the ~104-char sun_path limit (pytest's macOS tmp_path, /private/var/folders/.../pytest-of-runner/..., overflows it). Both fixtures already rmtree their sock_dir on teardown, so cleanup is unchanged. Co-Authored-By: Claude Opus 4.8 --- tests/test_mcp_tools.py | 8 ++++++-- tests/test_socket_disconnect_reconnect.py | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/test_mcp_tools.py b/tests/test_mcp_tools.py index 9d3a694..ded3b9a 100644 --- a/tests/test_mcp_tools.py +++ b/tests/test_mcp_tools.py @@ -33,8 +33,12 @@ def built_wrapper() -> Path: @pytest.fixture(scope="module") def daemon_sock() -> "Path": - sock_dir = tmp_path / "sock" - sock_dir.mkdir(parents=True, exist_ok=True) + # AF_UNIX sun_path is capped near 104 chars; pytest's tmp_path on macOS CI + # runners (/private/var/folders/.../pytest-of-runner/...) exceeds it, so the + # daemon can't bind. Bind under a short mkdtemp dir. This also fixes a + # NameError: tmp_path was never a parameter of this module-scoped fixture + # (and the function-scoped tmp_path isn't usable from module scope anyway). + sock_dir = Path(tempfile.mkdtemp(prefix="iai-sock-")) sock_path = sock_dir / "d.sock" store_dir = sock_dir / "store" store_dir.mkdir(parents=True, exist_ok=True) diff --git a/tests/test_socket_disconnect_reconnect.py b/tests/test_socket_disconnect_reconnect.py index 48d13c5..5908cd0 100644 --- a/tests/test_socket_disconnect_reconnect.py +++ b/tests/test_socket_disconnect_reconnect.py @@ -173,8 +173,10 @@ def _drop_fake_daemon_conn(proc: subprocess.Popen) -> None: @pytest.fixture def fake_daemon(): - sock_dir = tmp_path / "sock" - sock_dir.mkdir(parents=True, exist_ok=True) + # Short mkdtemp dir: AF_UNIX sun_path is capped near 104 chars and pytest's + # macOS CI tmp_path exceeds it, so the daemon can't bind. This also fixes a + # NameError — tmp_path was never a parameter of this fixture. + sock_dir = Path(tempfile.mkdtemp(prefix="iai-sock-")) sock_path = sock_dir / "d.sock" proc = _spawn_fake_daemon(sock_path)