From 5aba8a7c8116d7e9a92a3e954d487455300d51e7 Mon Sep 17 00:00:00 2001 From: Martin Hjelmare Date: Fri, 15 Oct 2021 18:36:26 +0200 Subject: [PATCH] Fix modem_callerid test warning (#57760) --- tests/components/modem_callerid/__init__.py | 5 +++-- tests/components/modem_callerid/test_init.py | 8 +++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/components/modem_callerid/__init__.py b/tests/components/modem_callerid/__init__.py index 2ff0e87c9cd..9564f2b662f 100644 --- a/tests/components/modem_callerid/__init__.py +++ b/tests/components/modem_callerid/__init__.py @@ -11,15 +11,16 @@ CONF_DATA = {CONF_DEVICE: DEFAULT_PORT} IMPORT_DATA = {"sensor": {"platform": "modem_callerid"}} -def _patch_init_modem(mocked_modem): +def _patch_init_modem(): return patch( "homeassistant.components.modem_callerid.PhoneModem", - return_value=mocked_modem, + autospec=True, ) def _patch_config_flow_modem(mocked_modem): return patch( "homeassistant.components.modem_callerid.config_flow.PhoneModem", + autospec=True, return_value=mocked_modem, ) diff --git a/tests/components/modem_callerid/test_init.py b/tests/components/modem_callerid/test_init.py index b288fb7dc9f..f467ca5af51 100644 --- a/tests/components/modem_callerid/test_init.py +++ b/tests/components/modem_callerid/test_init.py @@ -1,5 +1,5 @@ """Test Modem Caller ID integration.""" -from unittest.mock import AsyncMock, patch +from unittest.mock import patch from phone_modem import exceptions @@ -19,8 +19,7 @@ async def test_setup_config(hass: HomeAssistant): data=CONF_DATA, ) entry.add_to_hass(hass) - mocked_modem = AsyncMock() - with _patch_init_modem(mocked_modem): + with _patch_init_modem(): await hass.config_entries.async_setup(entry.entry_id) assert entry.state == ConfigEntryState.LOADED @@ -50,8 +49,7 @@ async def test_unload_config_entry(hass: HomeAssistant): data=CONF_DATA, ) entry.add_to_hass(hass) - mocked_modem = AsyncMock() - with _patch_init_modem(mocked_modem): + with _patch_init_modem(): await hass.config_entries.async_setup(entry.entry_id) assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert entry.state is ConfigEntryState.LOADED