From ffc331c46717ae628914b911442f520aa8447523 Mon Sep 17 00:00:00 2001 From: lapy Date: Tue, 13 Oct 2026 11:53:28 +0100 Subject: [PATCH] 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). --- .github/workflows/test.yml | 10 ++++++++-- main/xiaozhi-server/tests/conftest.py | 7 +++++++ scripts/westernization_rebase_check.sh | 10 +++++++--- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ab5225a3b..c72147d5f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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) diff --git a/main/xiaozhi-server/tests/conftest.py b/main/xiaozhi-server/tests/conftest.py index e9a6885a0..7795aef31 100644 --- a/main/xiaozhi-server/tests/conftest.py +++ b/main/xiaozhi-server/tests/conftest.py @@ -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 diff --git a/scripts/westernization_rebase_check.sh b/scripts/westernization_rebase_check.sh index 1f4a67f42..81434eaa2 100755 --- a/scripts/westernization_rebase_check.sh +++ b/scripts/westernization_rebase_check.sh @@ -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