test(tools): centralize disable_lazy_stt_install fixture in conftest

Move the autouse `_disable_lazy_stt_install` fixture out of the three
transcription test files and into `tests/tools/conftest.py` as a regular
(non-autouse) fixture. Each transcription test module opts in once at
the top via `pytestmark = pytest.mark.usefixtures(...)`.

Why: addresses three Copilot inline review comments on this PR that
flagged the verbatim duplication across files. Centralizing also keeps
the patch target in a single place, so a future rename of
`_try_lazy_install_stt` only updates one location.

Why opt-in (not autouse in conftest): other `tests/tools/` files do not
patch `_HAS_FASTER_WHISPER` and have no reason to bypass the runtime
lazy-install probe; making the fixture autouse globally would silently
mask any future test that wants to exercise the real lazy-install path.
This commit is contained in:
briandevans
2026-05-22 03:33:01 -07:00
committed by kshitij
parent 5dc232a6e2
commit 22b0d6dc1a
4 changed files with 28 additions and 42 deletions
+3 -14
View File
@@ -42,6 +42,9 @@ def sample_ogg(tmp_path):
return str(ogg_path)
pytestmark = pytest.mark.usefixtures("disable_lazy_stt_install")
@pytest.fixture(autouse=True)
def clean_env(monkeypatch):
"""Ensure no real API keys leak into tests."""
@@ -53,20 +56,6 @@ 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
# ============================================================================