Improve the mock_integration_frame test fixture (#139850)
* Improve the mock_integration_frame test fixture * Update testpull/139836/head^2
parent
1f24e5aec4
commit
cfaf18f942
|
@ -16,6 +16,7 @@ import reprlib
|
|||
from shutil import rmtree
|
||||
import sqlite3
|
||||
import ssl
|
||||
import sys
|
||||
import threading
|
||||
from typing import TYPE_CHECKING, Any, cast
|
||||
from unittest.mock import AsyncMock, MagicMock, Mock, _patch, patch
|
||||
|
@ -1889,12 +1890,15 @@ def mock_integration_frame(integration_frame_path: str) -> Generator[Mock]:
|
|||
Defaults to calling from `hue` core integration, and can be parametrized
|
||||
with `integration_frame_path`.
|
||||
"""
|
||||
correct_filename = f"/home/paulus/{integration_frame_path}/light.py"
|
||||
correct_module_name = f"{integration_frame_path.replace('/', '.')}.light"
|
||||
correct_frame = Mock(
|
||||
filename=f"/home/paulus/{integration_frame_path}/light.py",
|
||||
lineno="23",
|
||||
line="self.light.is_on",
|
||||
)
|
||||
with (
|
||||
patch.dict(sys.modules, {correct_module_name: Mock(__file__=correct_filename)}),
|
||||
patch(
|
||||
"homeassistant.helpers.frame.linecache.getline",
|
||||
return_value=correct_frame.line,
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# ---
|
||||
# name: test_report[custom integration default]
|
||||
list([
|
||||
"Detected that custom integration 'test_custom_integration' test_report_string at custom_components/test_custom_integration/light.py, line 23: self.light.is_on. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+test_custom_integration%22",
|
||||
"Detected that custom integration 'test_custom_integration' test_report_string at custom_components/test_custom_integration/light.py, line 23: self.light.is_on. Please report it to the author of the 'test_custom_integration' custom integration",
|
||||
])
|
||||
# ---
|
||||
# name: test_report[disable error_if_core]
|
||||
|
@ -25,7 +25,7 @@
|
|||
# ---
|
||||
# name: test_report[error_if_integration with custom integration]
|
||||
list([
|
||||
"Detected that custom integration 'test_integration_frame' test_report_string at custom_components/test_integration_frame/light.py, line 23: self.light.is_on. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+test_integration_frame%22",
|
||||
"Detected that custom integration 'test_integration_frame' test_report_string at custom_components/test_integration_frame/light.py, line 23: self.light.is_on. Please report it to the author of the 'test_integration_frame' custom integration",
|
||||
])
|
||||
# ---
|
||||
# name: test_report[log_custom_component_only with core integration]
|
||||
|
@ -34,7 +34,7 @@
|
|||
# ---
|
||||
# name: test_report[log_custom_component_only with custom integration]
|
||||
list([
|
||||
"Detected that custom integration 'test_integration_frame' test_report_string at custom_components/test_integration_frame/light.py, line 23: self.light.is_on. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+test_integration_frame%22",
|
||||
"Detected that custom integration 'test_integration_frame' test_report_string at custom_components/test_integration_frame/light.py, line 23: self.light.is_on. Please report it to the author of the 'test_integration_frame' custom integration",
|
||||
])
|
||||
# ---
|
||||
# name: test_report_usage[core default]
|
||||
|
@ -66,12 +66,12 @@
|
|||
# ---
|
||||
# name: test_report_usage[custom integration default]
|
||||
list([
|
||||
"Detected that custom integration 'test_custom_integration' test_report_string at custom_components/test_custom_integration/light.py, line 23: self.light.is_on. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+test_custom_integration%22",
|
||||
"Detected that custom integration 'test_custom_integration' test_report_string at custom_components/test_custom_integration/light.py, line 23: self.light.is_on. Please report it to the author of the 'test_custom_integration' custom integration",
|
||||
])
|
||||
# ---
|
||||
# name: test_report_usage[custom integration error]
|
||||
list([
|
||||
"Detected that custom integration 'test_custom_integration' test_report_string at custom_components/test_custom_integration/light.py, line 23: self.light.is_on. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+test_custom_integration%22",
|
||||
"Detected that custom integration 'test_custom_integration' test_report_string at custom_components/test_custom_integration/light.py, line 23: self.light.is_on. Please report it to the author of the 'test_custom_integration' custom integration",
|
||||
])
|
||||
# ---
|
||||
# name: test_report_usage[custom integration ignore]
|
||||
|
@ -95,7 +95,7 @@
|
|||
# ---
|
||||
# name: test_report_usage_find_issue_tracker[unknown custom integration]
|
||||
list([
|
||||
"Detected that custom integration 'unknown_custom_integration' test_report_string at custom_components/unknown_custom_integration/light.py, line 23: self.light.is_on. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+unknown_custom_integration%22",
|
||||
"Detected that custom integration 'unknown_custom_integration' test_report_string at custom_components/unknown_custom_integration/light.py, line 23: self.light.is_on. Please report it to the author of the 'unknown_custom_integration' custom integration",
|
||||
])
|
||||
# ---
|
||||
# name: test_report_usage_find_issue_tracker_other_thread[core integration]
|
||||
|
@ -110,11 +110,11 @@
|
|||
# ---
|
||||
# name: test_report_usage_find_issue_tracker_other_thread[custom integration]
|
||||
list([
|
||||
"Detected that custom integration 'test_custom_integration' test_report_string at custom_components/test_custom_integration/light.py, line 23: self.light.is_on. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+test_custom_integration%22",
|
||||
"Detected that custom integration 'test_custom_integration' test_report_string at custom_components/test_custom_integration/light.py, line 23: self.light.is_on. Please report it to the author of the 'test_custom_integration' custom integration",
|
||||
])
|
||||
# ---
|
||||
# name: test_report_usage_find_issue_tracker_other_thread[unknown custom integration]
|
||||
list([
|
||||
"Detected that custom integration 'unknown_custom_integration' test_report_string at custom_components/unknown_custom_integration/light.py, line 23: self.light.is_on. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+unknown_custom_integration%22",
|
||||
"Detected that custom integration 'unknown_custom_integration' test_report_string at custom_components/unknown_custom_integration/light.py, line 23: self.light.is_on. Please report it to the author of the 'unknown_custom_integration' custom integration",
|
||||
])
|
||||
# ---
|
||||
|
|
|
@ -23,7 +23,7 @@ async def test_extract_frame_integration(
|
|||
custom_integration=False,
|
||||
frame=mock_integration_frame,
|
||||
integration="hue",
|
||||
module=None,
|
||||
module="homeassistant.components.hue.light",
|
||||
relative_filename="homeassistant/components/hue/light.py",
|
||||
)
|
||||
|
||||
|
|
|
@ -8849,7 +8849,8 @@ async def test_options_flow_deprecated_config_entry_setter(
|
|||
"config_entry explicitly, which is deprecated at "
|
||||
"custom_components/my_integration/light.py, line 23: "
|
||||
"self.light.is_on. This will stop working in Home Assistant 2025.12, please "
|
||||
"create a bug report at " in caplog.text
|
||||
"report it to the author of the 'my_integration' custom integration"
|
||||
in caplog.text
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue