Clean up tts fixtures (#92025)

This commit is contained in:
Martin Hjelmare 2023-04-25 22:21:18 +02:00 committed by GitHub
parent 5244f5731e
commit 0594fefb0c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,7 +2,7 @@
From http://doc.pytest.org/en/latest/example/simple.html#making-test-result-information-available-in-fixtures
"""
from collections.abc import Callable, Generator
from collections.abc import Generator
from typing import Any
from unittest.mock import MagicMock, patch
@ -60,22 +60,14 @@ def mock_init_cache_dir(
@pytest.fixture
def init_cache_dir_side_effect(
hass: HomeAssistant,
) -> Callable[[HomeAssistant, str], str]:
def init_cache_dir_side_effect() -> Any:
"""Return the cache dir."""
def side_effect(hass: HomeAssistant, cache_dir: str) -> str:
"""Return the cache dir."""
return hass.config.path(cache_dir)
return side_effect
return None
@pytest.fixture
@pytest.fixture(autouse=True)
def empty_cache_dir(tmp_path, mock_init_cache_dir, mock_get_cache_files, request):
"""Mock the TTS cache dir with empty dir."""
mock_init_cache_dir.side_effect = None
mock_init_cache_dir.return_value = str(tmp_path)
# Restore original get cache files behavior, we're working with a real dir.