04d5633745
`monkeypatch.setitem(sys.modules, "hermes_cli.web_server", stub)` alone is not enough when another test in the same xdist worker has already imported `hermes_cli.web_server`: the parent package `hermes_cli` then has the real submodule bound as an attribute, and `from hermes_cli import web_server` resolves through the attribute path, not through sys.modules. Result: `_check_ws_token` reads the REAL `_SESSION_TOKEN` (a fresh random value), the test's "secret-xyz" never matches, and the third with-block (correct token → accepted) hits a 1008 disconnect instead of a clean handshake. Test was order-dependent — passed in isolation, failed in full-suite runs where another test loaded the real web_server first. Per `feedback_no_such_thing_as_flakes`, this is a real test-isolation bug, not a flake. Fix: also `monkeypatch.setattr(hermes_cli, "web_server", stub, raising=False)` so both lookup paths see the stub. Inline comment documents the gotcha for the next reader. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>