Skip to content

Commit

Permalink
Don't patch libraries that aren't installed in pytest (home-assistant…
Browse files Browse the repository at this point in the history
  • Loading branch information
davet2001 authored Jul 10, 2024
1 parent e0c7073 commit 311b1e2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/components/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,9 +21,9 @@
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,
Expand Down Expand Up @@ -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"
):
Expand Down

0 comments on commit 311b1e2

Please sign in to comment.