Ignore attribute-defined-outside-init pylint warnings in tests (#119470)

This commit is contained in:
epenet 2024-06-12 12:22:31 +02:00 committed by GitHub
parent 2a7e78a80f
commit 7d631c28a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 13 additions and 0 deletions

View file

@ -107,6 +107,7 @@ async def test_wrapped_bleak_client_local_adapter_only(hass: HomeAssistant) -> N
"00:00:00:00:00:01", "00:00:00:00:00:01",
"hci0", "hci0",
) )
# pylint: disable-next=attribute-defined-outside-init
scanner.connectable = True scanner.connectable = True
cancel = manager.async_register_scanner(scanner) cancel = manager.async_register_scanner(scanner)
inject_advertisement_with_source( inject_advertisement_with_source(

View file

@ -50,6 +50,7 @@ class FakeHarmonyClient:
self, ip_address: str = "", callbacks: ClientCallbackType = MagicMock() self, ip_address: str = "", callbacks: ClientCallbackType = MagicMock()
): ):
"""Initialize FakeHarmonyClient class to capture callbacks.""" """Initialize FakeHarmonyClient class to capture callbacks."""
# pylint: disable=attribute-defined-outside-init
self._activity_name = "Watch TV" self._activity_name = "Watch TV"
self.close = AsyncMock() self.close = AsyncMock()
self.send_commands = AsyncMock() self.send_commands = AsyncMock()

View file

@ -36,6 +36,7 @@ def _mock_cond_socket(sockname):
class CondMockSock(MagicMock): class CondMockSock(MagicMock):
def connect(self, addr): def connect(self, addr):
"""Mock connect that stores addr.""" """Mock connect that stores addr."""
# pylint: disable-next=attribute-defined-outside-init
self._addr = addr[0] self._addr = addr[0]
def getsockname(self): def getsockname(self):

View file

@ -467,6 +467,7 @@ def music_library_fixture(
def alarm_clock_fixture(): def alarm_clock_fixture():
"""Create alarmClock fixture.""" """Create alarmClock fixture."""
alarm_clock = SonosMockService("AlarmClock") alarm_clock = SonosMockService("AlarmClock")
# pylint: disable-next=attribute-defined-outside-init
alarm_clock.ListAlarms = Mock() alarm_clock.ListAlarms = Mock()
alarm_clock.ListAlarms.return_value = { alarm_clock.ListAlarms.return_value = {
"CurrentAlarmListVersion": "RINCON_test:14", "CurrentAlarmListVersion": "RINCON_test:14",
@ -484,6 +485,7 @@ def alarm_clock_fixture():
def alarm_clock_fixture_extended(): def alarm_clock_fixture_extended():
"""Create alarmClock fixture.""" """Create alarmClock fixture."""
alarm_clock = SonosMockService("AlarmClock") alarm_clock = SonosMockService("AlarmClock")
# pylint: disable-next=attribute-defined-outside-init
alarm_clock.ListAlarms = Mock() alarm_clock.ListAlarms = Mock()
alarm_clock.ListAlarms.return_value = { alarm_clock.ListAlarms.return_value = {
"CurrentAlarmListVersion": "RINCON_test:15", "CurrentAlarmListVersion": "RINCON_test:15",

View file

@ -132,6 +132,7 @@ class MockAsyncBulb:
def _mocked_bulb(cannot_connect=False): def _mocked_bulb(cannot_connect=False):
# pylint: disable=attribute-defined-outside-init
bulb = MockAsyncBulb(MODEL, BulbType.Color, cannot_connect) bulb = MockAsyncBulb(MODEL, BulbType.Color, cannot_connect)
type(bulb).async_get_properties = AsyncMock( type(bulb).async_get_properties = AsyncMock(
side_effect=BulbException if cannot_connect else None side_effect=BulbException if cannot_connect else None

View file

@ -107,6 +107,7 @@ async def test_async_update_support(hass: HomeAssistant) -> None:
"""Async update.""" """Async update."""
async_update.append(1) async_update.append(1)
# pylint: disable-next=attribute-defined-outside-init
ent.async_update = async_update_func ent.async_update = async_update_func
await ent.async_update_ha_state(True) await ent.async_update_ha_state(True)

View file

@ -94,8 +94,10 @@ async def test_polling_check_works_if_entity_add_fails(
return self.hass.data is not None return self.hass.data is not None
working_poll_ent = MockEntityNeedsSelfHassInShouldPoll(should_poll=True) working_poll_ent = MockEntityNeedsSelfHassInShouldPoll(should_poll=True)
# pylint: disable-next=attribute-defined-outside-init
working_poll_ent.async_update = AsyncMock() working_poll_ent.async_update = AsyncMock()
broken_poll_ent = MockEntityNeedsSelfHassInShouldPoll(should_poll=True) broken_poll_ent = MockEntityNeedsSelfHassInShouldPoll(should_poll=True)
# pylint: disable-next=attribute-defined-outside-init
broken_poll_ent.async_update = AsyncMock(side_effect=Exception("Broken")) broken_poll_ent.async_update = AsyncMock(side_effect=Exception("Broken"))
await component.async_add_entities( await component.async_add_entities(

View file

@ -68,7 +68,9 @@ def manager_fixture():
return result return result
mgr = FlowManager(None) mgr = FlowManager(None)
# pylint: disable-next=attribute-defined-outside-init
mgr.mock_created_entries = entries mgr.mock_created_entries = entries
# pylint: disable-next=attribute-defined-outside-init
mgr.mock_reg_handler = handlers.register mgr.mock_reg_handler = handlers.register
return mgr return mgr

View file

@ -47,7 +47,9 @@ def manager():
return result return result
mgr = FlowManager(None) mgr = FlowManager(None)
# pylint: disable-next=attribute-defined-outside-init
mgr.mock_created_entries = entries mgr.mock_created_entries = entries
# pylint: disable-next=attribute-defined-outside-init
mgr.mock_reg_handler = handlers.register mgr.mock_reg_handler = handlers.register
return mgr return mgr