mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Don't patch libraries that aren't installed in pytest (#121628)
This commit is contained in:
parent
e0c7073da1
commit
311b1e236a
@ -3,6 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable, Generator
|
||||
from importlib.util import find_spec
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Any
|
||||
from unittest.mock import MagicMock, patch
|
||||
@ -20,9 +21,9 @@ if TYPE_CHECKING:
|
||||
from .switch.common import MockSwitch
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
@pytest.fixture(scope="session", autouse=find_spec("zeroconf") is not None)
|
||||
def patch_zeroconf_multiple_catcher() -> Generator[None]:
|
||||
"""Patch zeroconf wrapper that detects if multiple instances are used."""
|
||||
"""If installed, patch zeroconf wrapper that detects if multiple instances are used."""
|
||||
with patch(
|
||||
"homeassistant.components.zeroconf.install_multiple_zeroconf_catcher",
|
||||
side_effect=lambda zc: None,
|
||||
@ -123,9 +124,9 @@ def mock_conversation_agent_fixture(hass: HomeAssistant) -> MockAgent:
|
||||
return mock_conversation_agent_fixture_helper(hass)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
@pytest.fixture(scope="session", autouse=find_spec("ffmpeg") is not None)
|
||||
def prevent_ffmpeg_subprocess() -> Generator[None]:
|
||||
"""Prevent ffmpeg from creating a subprocess."""
|
||||
"""If installed, prevent ffmpeg from creating a subprocess."""
|
||||
with patch(
|
||||
"homeassistant.components.ffmpeg.FFVersion.get_version", return_value="6.0"
|
||||
):
|
||||
|
Loading…
x
Reference in New Issue
Block a user