From 3737170d37b55f02aed5886c02ab06b505f41022 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 3 Jan 2023 17:32:39 +0100 Subject: [PATCH] Improve onewire tests (#85064) --- tests/components/onewire/test_binary_sensor.py | 5 +++-- tests/components/onewire/test_diagnostics.py | 5 +++-- tests/components/onewire/test_sensor.py | 5 +++-- tests/components/onewire/test_switch.py | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/components/onewire/test_binary_sensor.py b/tests/components/onewire/test_binary_sensor.py index 636228af143..399fd6ad86e 100644 --- a/tests/components/onewire/test_binary_sensor.py +++ b/tests/components/onewire/test_binary_sensor.py @@ -1,4 +1,5 @@ """Tests for 1-Wire binary sensors.""" +from collections.abc import Generator import logging from unittest.mock import MagicMock, patch @@ -21,7 +22,7 @@ from tests.common import mock_device_registry, mock_registry @pytest.fixture(autouse=True) -def override_platforms(): +def override_platforms() -> Generator[None, None, None]: """Override PLATFORMS.""" with patch("homeassistant.components.onewire.PLATFORMS", [Platform.BINARY_SENSOR]): yield @@ -33,7 +34,7 @@ async def test_binary_sensors( owproxy: MagicMock, device_id: str, caplog: pytest.LogCaptureFixture, -): +) -> None: """Test for 1-Wire binary sensor. This test forces all entities to be enabled. diff --git a/tests/components/onewire/test_diagnostics.py b/tests/components/onewire/test_diagnostics.py index e279e3a2633..8840c456b48 100644 --- a/tests/components/onewire/test_diagnostics.py +++ b/tests/components/onewire/test_diagnostics.py @@ -1,4 +1,5 @@ """Test 1-Wire diagnostics.""" +from collections.abc import Generator from unittest.mock import MagicMock, patch import pytest @@ -14,7 +15,7 @@ from tests.components.diagnostics import get_diagnostics_for_config_entry @pytest.fixture(autouse=True) -def override_platforms(): +def override_platforms() -> Generator[None, None, None]: """Override PLATFORMS.""" with patch("homeassistant.components.onewire.PLATFORMS", [Platform.SWITCH]): yield @@ -41,7 +42,7 @@ async def test_entry_diagnostics( hass_client, owproxy: MagicMock, device_id: str, -): +) -> None: """Test config entry diagnostics.""" setup_owproxy_mock_devices(owproxy, Platform.SENSOR, [device_id]) await hass.config_entries.async_setup(config_entry.entry_id) diff --git a/tests/components/onewire/test_sensor.py b/tests/components/onewire/test_sensor.py index a20714fedfc..123ccf7a506 100644 --- a/tests/components/onewire/test_sensor.py +++ b/tests/components/onewire/test_sensor.py @@ -1,4 +1,5 @@ """Tests for 1-Wire sensors.""" +from collections.abc import Generator import logging from unittest.mock import MagicMock, patch @@ -21,7 +22,7 @@ from tests.common import mock_device_registry, mock_registry @pytest.fixture(autouse=True) -def override_platforms(): +def override_platforms() -> Generator[None, None, None]: """Override PLATFORMS.""" with patch("homeassistant.components.onewire.PLATFORMS", [Platform.SENSOR]): yield @@ -33,7 +34,7 @@ async def test_sensors( owproxy: MagicMock, device_id: str, caplog: pytest.LogCaptureFixture, -): +) -> None: """Test for 1-Wire device. As they would be on a clean setup: all binary-sensors and switches disabled. diff --git a/tests/components/onewire/test_switch.py b/tests/components/onewire/test_switch.py index 8b60232330f..94e145d8cc7 100644 --- a/tests/components/onewire/test_switch.py +++ b/tests/components/onewire/test_switch.py @@ -1,4 +1,5 @@ """Tests for 1-Wire switches.""" +from collections.abc import Generator import logging from unittest.mock import MagicMock, patch @@ -29,7 +30,7 @@ from tests.common import mock_device_registry, mock_registry @pytest.fixture(autouse=True) -def override_platforms(): +def override_platforms() -> Generator[None, None, None]: """Override PLATFORMS.""" with patch("homeassistant.components.onewire.PLATFORMS", [Platform.SWITCH]): yield @@ -41,7 +42,7 @@ async def test_switches( owproxy: MagicMock, device_id: str, caplog: pytest.LogCaptureFixture, -): +) -> None: """Test for 1-Wire switch. This test forces all entities to be enabled.