core/tests/components/conftest.py

43 lines
1.3 KiB
Python
Raw Normal View History

"""Fixtures for component testing."""
from collections.abc import Generator
from unittest.mock import patch
2021-01-01 21:31:56 +00:00
import pytest
2023-05-24 19:00:35 +00:00
from tests.components.tts.conftest import ( # noqa: F401, pylint: disable=unused-import
init_tts_cache_dir_side_effect_fixture,
mock_tts_cache_dir_fixture,
mock_tts_get_cache_files_fixture,
mock_tts_init_cache_dir_fixture,
tts_mutagen_mock_fixture,
)
2021-04-25 18:16:38 +00:00
@pytest.fixture(scope="session", autouse=True)
def patch_zeroconf_multiple_catcher() -> Generator[None, None, None]:
2021-04-25 18:16:38 +00:00
"""Patch zeroconf wrapper that detects if multiple instances are used."""
with patch(
"homeassistant.components.zeroconf.install_multiple_zeroconf_catcher",
side_effect=lambda zc: None,
):
yield
@pytest.fixture(autouse=True)
def prevent_io() -> Generator[None, None, None]:
"""Fixture to prevent certain I/O from happening."""
2019-07-31 19:25:30 +00:00
with patch(
"homeassistant.components.http.ban.load_yaml_config_file",
2019-07-31 19:25:30 +00:00
):
yield
@pytest.fixture
def entity_registry_enabled_by_default() -> Generator[None, None, None]:
"""Test fixture that ensures all entities are enabled in the registry."""
with patch(
"homeassistant.helpers.entity.Entity.entity_registry_enabled_default",
return_value=True,
):
yield