diff --git a/tests/hermes_cli/conftest.py b/tests/hermes_cli/conftest.py index 3eee1b2f32f2a..2848a8a9aa238 100644 --- a/tests/hermes_cli/conftest.py +++ b/tests/hermes_cli/conftest.py @@ -41,6 +41,16 @@ def _suppress_concurrent_hermes_gate(request, monkeypatch): from hermes_cli import main as _cli_main except Exception: return + # raising=False: under pytest's per-test spawn isolation, a concurrent + # xdist worker importing a module that transitively touches hermes_cli.main + # can briefly expose a partially-initialized module object here — one where + # _detect_concurrent_hermes_instances isn't defined yet. A bare setattr + # would raise AttributeError and error the (unrelated) test. The attribute + # always exists once main.py finishes importing, so a no-op when it's + # transiently absent is the correct, race-free default. monkeypatch.setattr( - _cli_main, "_detect_concurrent_hermes_instances", lambda *_a, **_k: [] + _cli_main, + "_detect_concurrent_hermes_instances", + lambda *_a, **_k: [], + raising=False, )