From 9c3b0952e0c91158521894123845bb63ab85348b Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 29 Apr 2025 16:45:58 +0200 Subject: [PATCH] Turn off autospec for zeroconf mocks (#143879) --- tests/conftest.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 5e1a97863f8..a44c6bbb001 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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