Turn off autospec for zeroconf mocks (#143879)

This commit is contained in:
J. Nick Koston 2025-04-29 16:45:58 +02:00 committed by GitHub
parent c771f446b4
commit 9c3b0952e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1345,12 +1345,13 @@ def mock_zeroconf() -> Generator[MagicMock]:
from zeroconf import DNSCache # pylint: disable=import-outside-toplevel
with (
patch("homeassistant.components.zeroconf.HaZeroconf", autospec=True) as mock_zc,
patch("homeassistant.components.zeroconf.HaZeroconf") as mock_zc,
patch(
"homeassistant.components.zeroconf.discovery.AsyncServiceBrowser",
autospec=True,
),
) as mock_browser,
):
asb = mock_browser.return_value
asb.async_cancel = AsyncMock()
zc = mock_zc.return_value
# DNSCache has strong Cython type checks, and MagicMock does not work
# so we must mock the class directly