ArchiveAI-TTS / tests /conftest.py
billingsmoore's picture
Replace Kokoro TTS with ElevenLabs API
7b3dc39
Raw
History Blame Contribute Delete
580 Bytes
"""Shared fixtures and sys.modules pre-mocking for the ArchiveAI-TTS test suite."""
import sys
from unittest.mock import MagicMock
import pytest
def _mock_if_unimportable(name: str) -> None:
if name in sys.modules:
return
try:
__import__(name)
except (ImportError, ModuleNotFoundError):
sys.modules[name] = MagicMock()
# Mock only when not installed, so real environments use the real package.
for _pkg in ["elevenlabs", "gradio", "soundfile"]:
_mock_if_unimportable(_pkg)
@pytest.fixture
def tmp_dir(tmp_path):
return tmp_path