Improve the mock_integration_frame test fixture (#139850)
* Improve the mock_integration_frame test fixture * Update test
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user