mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-30 19:09:28 +00:00
fix(tests): tolerate mid-import kanban_db in the write-guard sys.modules probe
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.
This commit is contained in:
parent
ef1b06d853
commit
2d40494247
1 changed files with 9 additions and 1 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue