Files
VoiceStudio/tests/test_cpu_host_fixture.py
debpalash cceb879be3 test: pin a CPU host for native OmniVoice stubs (#3695)
On Apple Silicon the configured `omnivoice` engine resolves to the
crash-isolated MPS sidecar, which loads the real checkpoint in a child
process and never sees a test's in-process `get_model` stub, so 14 tests
passed on Linux CI and failed on every Mac. A shared `cpu_host` fixture
pins `detect_host_caps` (on the canonical module and every backend module
that bound it) and those tests use it.

Two more host leaks: the VirusTotal test compared an unresolved macOS
/var temp path with the script's resolved /private/var path, and a
storage-report test indexed `reason` on every warning, so a nearly full
test disk's real low_disk warning raised KeyError.

Inspired by #3695 by @rajkumar-madhu.
2026-11-09 17:31:58 +05:30

27 lines
1.1 KiB
Python

"""The shared ``cpu_host`` fixture makes native OmniVoice stubs host-independent (#3695).
On Apple Silicon the ``omnivoice`` id resolves to the crash-isolated MPS
sidecar, which never sees a test's in-process model stub.
"""
import importlib
import pytest
@pytest.fixture
def apple_silicon(monkeypatch):
device_caps = importlib.import_module("core.device_caps")
caps = device_caps.HostCaps(family="mps", available_families=("mps", "cpu"))
monkeypatch.setattr(device_caps, "detect_host_caps", lambda: caps)
def test_apple_silicon_routes_omnivoice_to_the_sidecar(apple_silicon):
tts_backend = importlib.import_module("services.tts_backend")
assert tts_backend.get_backend_class("omnivoice").__name__ == "OmniVoiceMPSSubprocessBackend"
def test_cpu_host_keeps_native_omnivoice_in_process(apple_silicon, cpu_host):
tts_backend = importlib.import_module("services.tts_backend")
assert tts_backend.get_backend_class("omnivoice").__name__ == "OmniVoiceBackend"
assert importlib.import_module("core.device_caps").detect_host_caps() is cpu_host