Add monkeypatch to enforce-type-hints plugin (#121051)

This commit is contained in:
epenet 2024-07-05 11:35:56 +02:00 committed by GitHub
parent d42dced852
commit e4731c07cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 6 additions and 5 deletions

View file

@ -146,6 +146,7 @@ _TEST_FIXTURES: dict[str, list[str] | str] = {
"mock_tts_get_cache_files": "MagicMock", "mock_tts_get_cache_files": "MagicMock",
"mock_tts_init_cache_dir": "MagicMock", "mock_tts_init_cache_dir": "MagicMock",
"mock_zeroconf": "MagicMock", "mock_zeroconf": "MagicMock",
"monkeypatch": "pytest.MonkeyPatch",
"mqtt_client_mock": "MqttMockPahoClient", "mqtt_client_mock": "MqttMockPahoClient",
"mqtt_mock": "MqttMockHAClient", "mqtt_mock": "MqttMockHAClient",
"mqtt_mock_entry": "MqttMockHAClientGenerator", "mqtt_mock_entry": "MqttMockHAClientGenerator",

View file

@ -61,7 +61,7 @@ def mock_is_file_fixture() -> Generator[MagicMock]:
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def mock_json(hass, monkeypatch): def mock_json(monkeypatch: pytest.MonkeyPatch) -> None:
"""Mock the event bus listener and os component.""" """Mock the event bus listener and os component."""
monkeypatch.setattr( monkeypatch.setattr(
f"{GOOGLE_PUBSUB_PATH}.json.dumps", Mock(return_value=MagicMock()) f"{GOOGLE_PUBSUB_PATH}.json.dumps", Mock(return_value=MagicMock())

View file

@ -43,7 +43,7 @@ class FilterTest:
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def mock_batch_timeout(hass, monkeypatch): def mock_batch_timeout(monkeypatch: pytest.MonkeyPatch) -> None:
"""Mock the event bus listener and the batch timeout for tests.""" """Mock the event bus listener and the batch timeout for tests."""
monkeypatch.setattr( monkeypatch.setattr(
f"{INFLUX_PATH}.InfluxThread.batch_timeout", f"{INFLUX_PATH}.InfluxThread.batch_timeout",

View file

@ -11,7 +11,7 @@ from homeassistant.const import STATE_ALARM_ARMED_AWAY, STATE_ALARM_DISARMED
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
async def test_valid_device_config(hass: HomeAssistant, monkeypatch) -> None: async def test_valid_device_config(hass: HomeAssistant) -> None:
"""Test valid device config.""" """Test valid device config."""
config = {"spc": {"api_url": "http://localhost/", "ws_url": "ws://localhost/"}} config = {"spc": {"api_url": "http://localhost/", "ws_url": "ws://localhost/"}}
@ -22,7 +22,7 @@ async def test_valid_device_config(hass: HomeAssistant, monkeypatch) -> None:
assert await async_setup_component(hass, "spc", config) is True assert await async_setup_component(hass, "spc", config) is True
async def test_invalid_device_config(hass: HomeAssistant, monkeypatch) -> None: async def test_invalid_device_config(hass: HomeAssistant) -> None:
"""Test valid device config.""" """Test valid device config."""
config = {"spc": {"api_url": "http://localhost/"}} config = {"spc": {"api_url": "http://localhost/"}}

View file

@ -865,7 +865,7 @@ def schema():
@pytest.fixture @pytest.fixture
def version(monkeypatch): def version(monkeypatch: pytest.MonkeyPatch) -> None:
"""Patch the version used for testing to 0.5.0.""" """Patch the version used for testing to 0.5.0."""
monkeypatch.setattr(homeassistant.const, "__version__", "0.5.0") monkeypatch.setattr(homeassistant.const, "__version__", "0.5.0")