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