mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Reset helpers.frame._REPORTED_INTEGRATIONS in between tests (#139924)
* Reset helpers.frame._REPORTED_INTEGRATIONS in between tests * Rename * Apply suggestions from code review Co-authored-by: Erik Montnemery <erik@montnemery.com> --------- Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
parent
1a4a3a0f08
commit
377e0a64d1
@ -1,7 +1,6 @@
|
||||
"""Test for the alarm control panel const module."""
|
||||
|
||||
from typing import Any
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
@ -23,7 +22,7 @@ from homeassistant.const import (
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ServiceValidationError
|
||||
from homeassistant.helpers import entity_registry as er, frame
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.helpers.typing import UNDEFINED, UndefinedType
|
||||
|
||||
from . import help_async_setup_entry_init, help_async_unload_entry
|
||||
@ -222,7 +221,6 @@ async def test_alarm_control_panel_with_default_code(
|
||||
mock_alarm_control_panel_entity.calls_disarm.assert_called_with("1234")
|
||||
|
||||
|
||||
@patch.object(frame, "_REPORTED_INTEGRATIONS", set())
|
||||
async def test_alarm_control_panel_not_log_deprecated_state_warning(
|
||||
hass: HomeAssistant,
|
||||
mock_alarm_control_panel_entity: MockAlarmControlPanel,
|
||||
@ -238,7 +236,6 @@ async def test_alarm_control_panel_not_log_deprecated_state_warning(
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_as_custom_component")
|
||||
@patch.object(frame, "_REPORTED_INTEGRATIONS", set())
|
||||
async def test_alarm_control_panel_log_deprecated_state_warning_using_state_prop(
|
||||
hass: HomeAssistant,
|
||||
code_format: CodeFormat | None,
|
||||
@ -303,7 +300,6 @@ async def test_alarm_control_panel_log_deprecated_state_warning_using_state_prop
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_as_custom_component")
|
||||
@patch.object(frame, "_REPORTED_INTEGRATIONS", set())
|
||||
async def test_alarm_control_panel_log_deprecated_state_warning_using_attr_state_attr(
|
||||
hass: HomeAssistant,
|
||||
code_format: CodeFormat | None,
|
||||
@ -386,7 +382,6 @@ async def test_alarm_control_panel_log_deprecated_state_warning_using_attr_state
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_as_custom_component")
|
||||
@patch.object(frame, "_REPORTED_INTEGRATIONS", set())
|
||||
async def test_alarm_control_panel_deprecated_state_does_not_break_state(
|
||||
hass: HomeAssistant,
|
||||
code_format: CodeFormat | None,
|
||||
|
@ -21,7 +21,6 @@ from homeassistant.const import (
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError, Unauthorized
|
||||
from homeassistant.helpers import frame
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util import color as color_util
|
||||
|
||||
@ -2846,7 +2845,6 @@ def test_report_invalid_color_modes(
|
||||
],
|
||||
ids=["with_kelvin", "with_mired_values", "with_mired_defaults"],
|
||||
)
|
||||
@patch.object(frame, "_REPORTED_INTEGRATIONS", set())
|
||||
def test_missing_kelvin_property_warnings(
|
||||
hass: HomeAssistant,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
|
@ -114,7 +114,6 @@ async def test_async_resolve_media(hass: HomeAssistant) -> None:
|
||||
assert media.mime_type == "audio/mpeg"
|
||||
|
||||
|
||||
@patch("homeassistant.helpers.frame._REPORTED_INTEGRATIONS", set())
|
||||
async def test_async_resolve_media_no_entity(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
|
@ -5,7 +5,6 @@ from __future__ import annotations
|
||||
from enum import Enum
|
||||
from types import ModuleType
|
||||
from typing import Any
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
@ -25,7 +24,6 @@ from homeassistant.components.vacuum import (
|
||||
VacuumEntityFeature,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import frame
|
||||
|
||||
from . import MockVacuum, help_async_setup_entry_init, help_async_unload_entry
|
||||
from .common import async_start
|
||||
@ -326,7 +324,6 @@ async def test_vacuum_not_log_deprecated_state_warning(
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_as_custom_component")
|
||||
@patch.object(frame, "_REPORTED_INTEGRATIONS", set())
|
||||
async def test_vacuum_log_deprecated_state_warning_using_state_prop(
|
||||
hass: HomeAssistant,
|
||||
config_flow_fixture: None,
|
||||
@ -371,7 +368,6 @@ async def test_vacuum_log_deprecated_state_warning_using_state_prop(
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_as_custom_component")
|
||||
@patch.object(frame, "_REPORTED_INTEGRATIONS", set())
|
||||
async def test_vacuum_log_deprecated_state_warning_using_attr_state_attr(
|
||||
hass: HomeAssistant,
|
||||
config_flow_fixture: None,
|
||||
@ -429,7 +425,6 @@ async def test_vacuum_log_deprecated_state_warning_using_attr_state_attr(
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_as_custom_component")
|
||||
@patch.object(frame, "_REPORTED_INTEGRATIONS", set())
|
||||
async def test_vacuum_deprecated_state_does_not_break_state(
|
||||
hass: HomeAssistant,
|
||||
config_flow_fixture: None,
|
||||
|
@ -430,11 +430,16 @@ def verify_cleanup(
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def reset_hass_threading_local_object() -> Generator[None]:
|
||||
"""Reset the _Hass threading.local object for every test case."""
|
||||
def reset_globals() -> Generator[None]:
|
||||
"""Reset global objects for every test case."""
|
||||
yield
|
||||
|
||||
# Reset the _Hass threading.local object
|
||||
ha._hass.__dict__.clear()
|
||||
|
||||
# Reset the frame helper globals
|
||||
frame.async_setup(None)
|
||||
frame._REPORTED_INTEGRATIONS.clear()
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True, scope="session")
|
||||
|
@ -249,7 +249,6 @@ async def test_get_clientsession_patched_close(hass: HomeAssistant) -> None:
|
||||
assert mock_close.call_count == 0
|
||||
|
||||
|
||||
@patch("homeassistant.helpers.frame._REPORTED_INTEGRATIONS", set())
|
||||
async def test_warning_close_session_integration(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
@ -292,7 +291,6 @@ async def test_warning_close_session_integration(
|
||||
) in caplog.text
|
||||
|
||||
|
||||
@patch("homeassistant.helpers.frame._REPORTED_INTEGRATIONS", set())
|
||||
async def test_warning_close_session_custom(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
|
@ -376,7 +376,6 @@ async def test_report_usage_find_issue_tracker_other_thread(
|
||||
assert reports == snapshot
|
||||
|
||||
|
||||
@patch.object(frame, "_REPORTED_INTEGRATIONS", set())
|
||||
@pytest.mark.usefixtures("hass", "mock_integration_frame")
|
||||
async def test_prevent_flooding(
|
||||
caplog: pytest.LogCaptureFixture, mock_integration_frame: Mock
|
||||
@ -408,7 +407,6 @@ async def test_prevent_flooding(
|
||||
assert len(frame._REPORTED_INTEGRATIONS) == 1
|
||||
|
||||
|
||||
@patch.object(frame, "_REPORTED_INTEGRATIONS", set())
|
||||
@pytest.mark.usefixtures("hass", "mock_integration_frame")
|
||||
async def test_breaks_in_ha_version(
|
||||
caplog: pytest.LogCaptureFixture, mock_integration_frame: Mock
|
||||
|
@ -100,7 +100,6 @@ async def test_get_async_client_context_manager(hass: HomeAssistant) -> None:
|
||||
assert mock_aclose.call_count == 0
|
||||
|
||||
|
||||
@patch("homeassistant.helpers.frame._REPORTED_INTEGRATIONS", set())
|
||||
async def test_warning_close_session_integration(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
@ -144,7 +143,6 @@ async def test_warning_close_session_integration(
|
||||
) in caplog.text
|
||||
|
||||
|
||||
@patch("homeassistant.helpers.frame._REPORTED_INTEGRATIONS", set())
|
||||
async def test_warning_close_session_custom(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
|
@ -19,7 +19,7 @@ from homeassistant.exceptions import (
|
||||
ConfigEntryError,
|
||||
ConfigEntryNotReady,
|
||||
)
|
||||
from homeassistant.helpers import frame, update_coordinator
|
||||
from homeassistant.helpers import update_coordinator
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
@ -638,7 +638,6 @@ async def test_async_config_entry_first_refresh_invalid_state(
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_integration_frame")
|
||||
@patch.object(frame, "_REPORTED_INTEGRATIONS", set())
|
||||
async def test_async_config_entry_first_refresh_invalid_state_in_integration(
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
|
@ -5763,7 +5763,6 @@ async def test_reauth_reconfigure_missing_entry(
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_integration_frame")
|
||||
@patch.object(frame, "_REPORTED_INTEGRATIONS", set())
|
||||
@pytest.mark.parametrize(
|
||||
"source", [config_entries.SOURCE_REAUTH, config_entries.SOURCE_RECONFIGURE]
|
||||
)
|
||||
@ -6010,7 +6009,6 @@ async def test_options_flow_with_config_entry_core() -> None:
|
||||
|
||||
@pytest.mark.parametrize("integration_frame_path", ["custom_components/my_integration"])
|
||||
@pytest.mark.usefixtures("hass", "mock_integration_frame")
|
||||
@patch.object(frame, "_REPORTED_INTEGRATIONS", set())
|
||||
async def test_options_flow_with_config_entry(caplog: pytest.LogCaptureFixture) -> None:
|
||||
"""Test that OptionsFlowWithConfigEntry doesn't mutate entry options."""
|
||||
entry = MockConfigEntry(
|
||||
@ -8789,7 +8787,6 @@ async def test_options_flow_config_entry(
|
||||
|
||||
@pytest.mark.parametrize("integration_frame_path", ["custom_components/my_integration"])
|
||||
@pytest.mark.usefixtures("mock_integration_frame")
|
||||
@patch.object(frame, "_REPORTED_INTEGRATIONS", set())
|
||||
async def test_options_flow_deprecated_config_entry_setter(
|
||||
hass: HomeAssistant,
|
||||
manager: config_entries.ConfigEntries,
|
||||
|
@ -15,7 +15,6 @@ from homeassistant import loader
|
||||
from homeassistant.components import http, hue
|
||||
from homeassistant.components.hue import light as hue_light
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import frame
|
||||
from homeassistant.helpers.json import json_dumps
|
||||
from homeassistant.util.json import json_loads
|
||||
|
||||
@ -1314,7 +1313,6 @@ async def test_config_folder_not_in_path() -> None:
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_integration_frame")
|
||||
@patch.object(frame, "_REPORTED_INTEGRATIONS", set())
|
||||
async def test_hass_components_use_reported(
|
||||
hass: HomeAssistant,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
@ -2010,7 +2008,6 @@ async def test_has_services(hass: HomeAssistant) -> None:
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_integration_frame")
|
||||
@patch.object(frame, "_REPORTED_INTEGRATIONS", set())
|
||||
async def test_hass_helpers_use_reported(
|
||||
hass: HomeAssistant,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
|
Loading…
x
Reference in New Issue
Block a user