From 69ab856d372abbeb678e8417ee433be9e403def4 Mon Sep 17 00:00:00 2001 From: nesquena-hermes <226517000+nesquena-hermes@users.noreply.github.com> Date: Fri, 1 May 2026 22:45:18 +0000 Subject: [PATCH] test fix: skip test_session_db_close_is_idempotent when hermes_state not on import path CI-only failure: test_session_db_close_is_idempotent imported hermes_state from /home/hermes/.hermes/hermes-agent which exists locally but NOT on the GH Actions runner that only has the WebUI repo. Use importlib.util.find_spec to detect availability and pytest.skip when the agent repo isn't present. The source-level pin in test_cached_agent_reuse_closes_old_session_db catches revert of the close() call; the runtime idempotency test is added confirmation when both repos are co-located. Local: 5 passed. CI: 4 passed + 1 skipped (idempotency). --- tests/test_v050259_sessiondb_fd_leak.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/test_v050259_sessiondb_fd_leak.py b/tests/test_v050259_sessiondb_fd_leak.py index e361a5d0..80290fc7 100644 --- a/tests/test_v050259_sessiondb_fd_leak.py +++ b/tests/test_v050259_sessiondb_fd_leak.py @@ -20,6 +20,8 @@ from __future__ import annotations import os from pathlib import Path +import pytest + REPO = Path(__file__).resolve().parents[1] @@ -96,10 +98,18 @@ def test_lru_eviction_closes_evicted_agent_session_db(): def test_session_db_close_is_idempotent(): """`SessionDB.close()` must be safe to call multiple times. The fix relies on this — if a future code path closes the same `_session_db` - after we've swapped it, the second close is a benign no-op.""" - import sys - sys.path.insert(0, "/home/hermes/.hermes/hermes-agent") - from hermes_state import SessionDB + after we've swapped it, the second close is a benign no-op. + + Skipped when hermes_state is not on the import path (e.g. on the GH + Actions runner that only has the WebUI repo, not the agent repo). + The source-level pin in test_cached_agent_reuse_closes_old_session_db + catches revert of the close() call; this test only adds runtime + confirmation when both repos are co-located. + """ + import importlib.util + if importlib.util.find_spec("hermes_state") is None: + pytest.skip("hermes_state not on import path (CI-only — agent repo not present)") + from hermes_state import SessionDB # type: ignore import tempfile with tempfile.TemporaryDirectory() as tmpd: