diff --git a/tests/tools/test_transcription.py b/tests/tools/test_transcription.py index 32f0ad48798..606a3e100a2 100644 --- a/tests/tools/test_transcription.py +++ b/tests/tools/test_transcription.py @@ -28,6 +28,20 @@ def _clear_openai_env(monkeypatch): monkeypatch.delenv("OPENAI_API_KEY", raising=False) +@pytest.fixture(autouse=True) +def _disable_lazy_stt_install(): + """Disarm the runtime lazy-install probe so static ``_HAS_FASTER_WHISPER`` + patches accurately simulate 'faster-whisper not installed'. + + Without this, ``_try_lazy_install_stt()`` calls + ``importlib.util.find_spec("faster_whisper")``, which returns truthy + whenever the package is installed in the dev / CI environment — + defeating the test's ``_HAS_FASTER_WHISPER=False`` patch. + """ + with patch("tools.transcription_tools._try_lazy_install_stt", return_value=False): + yield + + class TestGetProvider: """_get_provider() picks the right backend based on config + availability.""" diff --git a/tests/tools/test_transcription_dotenv_fallback.py b/tests/tools/test_transcription_dotenv_fallback.py index 365b910d4cc..6248d0acd06 100644 --- a/tests/tools/test_transcription_dotenv_fallback.py +++ b/tests/tools/test_transcription_dotenv_fallback.py @@ -28,6 +28,20 @@ def isolate_env(monkeypatch): monkeypatch.delenv(key, raising=False) +@pytest.fixture(autouse=True) +def _disable_lazy_stt_install(): + """Disarm the runtime lazy-install probe so static ``_HAS_FASTER_WHISPER`` + patches accurately simulate 'faster-whisper not installed'. + + Without this, ``_try_lazy_install_stt()`` calls + ``importlib.util.find_spec("faster_whisper")``, which returns truthy + whenever the package is installed in the dev / CI environment — + defeating the test's ``_HAS_FASTER_WHISPER=False`` patch. + """ + with patch("tools.transcription_tools._try_lazy_install_stt", return_value=False): + yield + + class TestProviderSelectionGate: """``_get_provider`` picks the STT backend. If it only consulted ``os.environ`` a user with keys in ``~/.hermes/.env`` would be told diff --git a/tests/tools/test_transcription_tools.py b/tests/tools/test_transcription_tools.py index 7f83565b5d8..953a68be79e 100644 --- a/tests/tools/test_transcription_tools.py +++ b/tests/tools/test_transcription_tools.py @@ -53,6 +53,20 @@ def clean_env(monkeypatch): monkeypatch.delenv("HERMES_LOCAL_STT_LANGUAGE", raising=False) +@pytest.fixture(autouse=True) +def _disable_lazy_stt_install(): + """Disarm the runtime lazy-install probe so static ``_HAS_FASTER_WHISPER`` + patches accurately simulate 'faster-whisper not installed'. + + Without this, ``_try_lazy_install_stt()`` calls + ``importlib.util.find_spec("faster_whisper")``, which returns truthy + whenever the package is installed in the dev / CI environment — + defeating the test's ``_HAS_FASTER_WHISPER=False`` patch. + """ + with patch("tools.transcription_tools._try_lazy_install_stt", return_value=False): + yield + + # ============================================================================ # _get_provider — full permutation matrix # ============================================================================