From 13983b614af514fc515afbc8b7076d09e010969e Mon Sep 17 00:00:00 2001 From: AIOSAI Date: Mon, 29 Jun 2026 14:16:02 -0700 Subject: [PATCH] =?UTF-8?q?fix(hooks):=20presence=20tests=20cross-platform?= =?UTF-8?q?=20=E2=80=94=20patch=20=5Fpresence=5Flock=20not=20fcntl=20(FPLA?= =?UTF-8?q?N-0289=20P1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Windows CI was red on f460cd5: the patch_flock fixture patched presence.fcntl, which only exists on POSIX (msvcrt on win32), erroring all 16 presence-test setups. Now patches the platform-agnostic _presence_lock context manager (-> nullcontext per call) and skips the inherently-POSIX flock-acquire test on win32. Dormant prod code unchanged. 705 tests pass, seedgo 100%. Fix by @hooks. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01GFihce1oLtp6UDAPGryYSv --- src/aipass/hooks/tests/test_presence.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/aipass/hooks/tests/test_presence.py b/src/aipass/hooks/tests/test_presence.py index da627542..b7355186 100644 --- a/src/aipass/hooks/tests/test_presence.py +++ b/src/aipass/hooks/tests/test_presence.py @@ -1,6 +1,8 @@ """Tests for the presence service module.""" import json +import sys +from contextlib import nullcontext from unittest.mock import patch import pytest @@ -31,11 +33,9 @@ def patch_paths(presence_dir): @pytest.fixture def patch_flock(): - """Patch flock to be a no-op (avoid real file locking in tests).""" - with patch("aipass.hooks.apps.modules.presence.fcntl") as mock_fcntl: - mock_fcntl.LOCK_EX = 2 - mock_fcntl.LOCK_UN = 8 - yield mock_fcntl + """Make the presence lock a no-op (avoid real file locking in tests).""" + with patch.object(presence, "_presence_lock", side_effect=lambda: nullcontext()): + yield # ── claim tests ────────────────────────────────────────────────────────── @@ -390,6 +390,7 @@ class TestLiveness: class TestFileLocking: + @pytest.mark.skipif(sys.platform == "win32", reason="fcntl is POSIX-only") def test_presence_lock_acquires_flock(self, patch_paths): with patch("aipass.hooks.apps.modules.presence.fcntl") as mock_fcntl: mock_fcntl.LOCK_EX = 2