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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user