test(server): shim edge_tts.communicate so upstream WSS_URL monkey-patch imports in mock mode

Upstream's edge-tts workaround (msedgeservices 403 fix) now imports
edge_tts.communicate explicitly; the conftest shim only registered the
.exceptions submodule, so 4 tts tests failed after the sync. Same pattern
as the existing opuslib_next submodule shims.

Also widen CI + rebase gate from smoke-only to the full pytest suite and
the unittest-only lifecycle tests (the smoke run masked these failures).
This commit is contained in:
lapy 2026-10-13 11:53:28 +01:00
parent df6fc3ae76
commit ffc331c467
3 changed files with 22 additions and 5 deletions

View file

@ -33,10 +33,16 @@ jobs:
run: |
pip install -r requirements.txt
pip install pytest pytest-asyncio freezegun
- name: Run smoke test
- name: Run tests
working-directory: main/xiaozhi-server
run: |
pytest tests/test_smoke.py -x -q
pytest tests/ -q
- name: Run unittest-only lifecycle tests
working-directory: main/xiaozhi-server
env:
PYTHONPATH: .
run: |
python3 -B -m unittest discover -s tests -p 'test_*lifecycle*.py'
java:
name: Java (manager-api)

View file

@ -310,6 +310,13 @@ def _install_mock_layer() -> None:
shim.exceptions = _ShimModule(f"{name}.exceptions")
sys.modules[name] = shim
sys.modules[f"{name}.exceptions"] = shim.exceptions
if name == "edge_tts":
# core/providers/tts/edge.py imports edge_tts.communicate explicitly
# to monkey-patch WSS_URL; provide the submodule shim so the import
# resolves in mock mode (same pattern as opuslib_next above).
_comm = _ShimModule(f"{name}.communicate")
shim.communicate = _comm
sys.modules[f"{name}.communicate"] = _comm
# Shorten asyncio.sleep to prevent retry loops from delaying execution.
import asyncio

View file

@ -58,10 +58,14 @@ else
fi
if command -v python3 >/dev/null 2>&1 && python3 -c 'import pytest' >/dev/null 2>&1; then
( cd main/xiaozhi-server && PYTHONPATH=. pytest tests/test_smoke.py -q ) \
&& echo "--- PASS: python smoke" || { echo "--- FAIL: python smoke"; fail=1; }
( cd main/xiaozhi-server && PYTHONPATH=. pytest tests/ -q ) \
&& echo "--- PASS: python tests" || { echo "--- FAIL: python tests"; fail=1; }
# Upstream ships unittest-only lifecycle tests (excluded from pytest via
# __test__ = False); run them explicitly.
( cd main/xiaozhi-server && PYTHONPATH=. python3 -B -m unittest discover -s tests -p 'test_*lifecycle*.py' ) \
&& echo "--- PASS: python lifecycle tests" || { echo "--- FAIL: python lifecycle tests"; fail=1; }
else
echo "==> pytest not present - skipping python smoke"
echo "==> pytest not present - skipping python tests"
fi
echo