From 2d404942471633d5338a8ff514ea7da24549274f Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 29 Jul 2026 19:36:03 -0700 Subject: [PATCH] fix(tests): tolerate mid-import kanban_db in the write-guard sys.modules probe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The guard's sys.modules.get() can observe hermes_cli.kanban_db while a lazy import is still executing on a fixture boundary — the partially initialized module has no .connect yet (AttributeError flake in the full-suite verification run, 1/2460 files). A half-imported module has no callers to guard; skip this round and let the next fixture patch the completed module. --- tests/conftest.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 788e5cbafd8..5584e21eddc 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -597,7 +597,15 @@ def _kanban_write_guard(_hermetic_environment, monkeypatch): if _kdb is None: return - _orig_connect = _kdb.connect + # The sys.modules probe can observe the module MID-IMPORT: a fixture + # boundary firing while another test's lazy `import hermes_cli.kanban_db` + # is still executing sees a partially initialized module whose `connect` + # doesn't exist yet (AttributeError flake, caught in a full-suite run). + # A half-imported module has no callers yet either — nothing to guard + # this round; the next test's fixture will patch the completed module. + _orig_connect = getattr(_kdb, "connect", None) + if _orig_connect is None: + return def _guarded_connect(db_path=None, *args, **kwargs): if db_path is not None: