fix: resolve websocket-client shadowing src/websocket on CI

selenium depends on websocket-client which installs a top-level
`websocket` package that shadows our src/websocket/ module.  Ensure
src/ is inserted at the front of sys.path in conftest so the project
module wins the import race.  Fixes collection errors for
test_websocket.py and test_websocket_extended.py on GitHub Actions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Alexander Payne
2026-02-25 07:32:57 -05:00
parent 29292cfb84
commit e483748816

View File

@@ -6,6 +6,15 @@ import sys
from pathlib import Path
from unittest.mock import MagicMock
# ── Fix websocket-client shadowing project's src/websocket/ ──────────────────
# selenium → websocket-client installs a top-level `websocket` package that
# shadows our src/websocket/ module. Ensure src/ is at the FRONT of sys.path
# so our module wins the import race.
_src = str(Path(__file__).resolve().parent.parent / "src")
if _src in sys.path:
sys.path.remove(_src)
sys.path.insert(0, _src)
import pytest
from fastapi.testclient import TestClient