Use TypeVar defaults for Generator (#125228)
This commit is contained in:
parent
fbd3bf7a98
commit
c8fd48523f
6 changed files with 16 additions and 20 deletions
tests/components
fujitsu_fglair
google_photos
intellifire
smlight
yale
|
@ -30,7 +30,7 @@ TEST_PROPERTY_VALUES = {
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
||||
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||
"""Override async_setup_entry."""
|
||||
with patch(
|
||||
"homeassistant.components.fujitsu_fglair.async_setup_entry", return_value=True
|
||||
|
|
|
@ -125,7 +125,7 @@ def mock_client_api(
|
|||
fixture_name: str,
|
||||
user_identifier: str,
|
||||
api_error: Exception,
|
||||
) -> Generator[Mock, None, None]:
|
||||
) -> Generator[Mock]:
|
||||
"""Set up fake Google Photos API responses from fixtures."""
|
||||
mock_api = AsyncMock(GooglePhotosLibraryApi, autospec=True)
|
||||
mock_api.get_user_info.return_value = UserInfoResult(
|
||||
|
@ -136,9 +136,7 @@ def mock_client_api(
|
|||
|
||||
responses = load_json_array_fixture(fixture_name, DOMAIN) if fixture_name else []
|
||||
|
||||
async def list_media_items(
|
||||
*args: Any,
|
||||
) -> AsyncGenerator[ListMediaItemResult, None, None]:
|
||||
async def list_media_items(*args: Any) -> AsyncGenerator[ListMediaItemResult]:
|
||||
for response in responses:
|
||||
mock_list_media_items = Mock(ListMediaItemResult)
|
||||
mock_list_media_items.media_items = [
|
||||
|
@ -163,9 +161,7 @@ def mock_client_api(
|
|||
# Emulate an async iterator for returning pages of response objects. We just
|
||||
# return a single page.
|
||||
|
||||
async def list_albums(
|
||||
*args: Any, **kwargs: Any
|
||||
) -> AsyncGenerator[ListAlbumResult, None, None]:
|
||||
async def list_albums(*args: Any, **kwargs: Any) -> AsyncGenerator[ListAlbumResult]:
|
||||
mock_list_album_result = Mock(ListAlbumResult)
|
||||
mock_list_album_result.albums = [
|
||||
Album.from_dict(album)
|
||||
|
|
|
@ -28,7 +28,7 @@ CLIENT_SECRET = "5678"
|
|||
|
||||
|
||||
@pytest.fixture(name="mock_setup")
|
||||
def mock_setup_entry() -> Generator[Mock, None, None]:
|
||||
def mock_setup_entry() -> Generator[Mock]:
|
||||
"""Fixture to mock out integration setup."""
|
||||
with patch(
|
||||
"homeassistant.components.google_photos.async_setup_entry", return_value=True
|
||||
|
@ -37,7 +37,7 @@ def mock_setup_entry() -> Generator[Mock, None, None]:
|
|||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_patch_api(mock_api: Mock) -> Generator[None, None, None]:
|
||||
def mock_patch_api(mock_api: Mock) -> Generator[None]:
|
||||
"""Fixture to patch the config flow api."""
|
||||
with patch(
|
||||
"homeassistant.components.google_photos.config_flow.GooglePhotosLibraryApi",
|
||||
|
|
|
@ -34,7 +34,7 @@ from tests.common import MockConfigEntry, load_json_object_fixture
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
||||
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||
"""Mock setting up a config entry."""
|
||||
with patch(
|
||||
"homeassistant.components.intellifire.async_setup_entry", return_value=True
|
||||
|
@ -43,7 +43,7 @@ def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_fireplace_finder_none() -> Generator[None, MagicMock, None]:
|
||||
def mock_fireplace_finder_none() -> Generator[MagicMock]:
|
||||
"""Mock fireplace finder."""
|
||||
mock_found_fireplaces = Mock()
|
||||
mock_found_fireplaces.ips = []
|
||||
|
@ -110,7 +110,7 @@ def mock_common_data_local() -> IntelliFireCommonFireplaceData:
|
|||
@pytest.fixture
|
||||
def mock_apis_multifp(
|
||||
mock_cloud_interface, mock_local_interface, mock_fp
|
||||
) -> Generator[tuple[AsyncMock, AsyncMock, MagicMock], None, None]:
|
||||
) -> Generator[tuple[AsyncMock, AsyncMock, MagicMock]]:
|
||||
"""Multi fireplace version of mocks."""
|
||||
return mock_local_interface, mock_cloud_interface, mock_fp
|
||||
|
||||
|
@ -118,7 +118,7 @@ def mock_apis_multifp(
|
|||
@pytest.fixture
|
||||
def mock_apis_single_fp(
|
||||
mock_cloud_interface, mock_local_interface, mock_fp
|
||||
) -> Generator[tuple[AsyncMock, AsyncMock, MagicMock], None, None]:
|
||||
) -> Generator[tuple[AsyncMock, AsyncMock, MagicMock]]:
|
||||
"""Single fire place version of the mocks."""
|
||||
data_v1 = IntelliFireUserData(
|
||||
**load_json_object_fixture("user_data_1.json", DOMAIN)
|
||||
|
@ -131,7 +131,7 @@ def mock_apis_single_fp(
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_cloud_interface() -> Generator[AsyncMock, None, None]:
|
||||
def mock_cloud_interface() -> Generator[AsyncMock]:
|
||||
"""Mock cloud interface to use for testing."""
|
||||
user_data = IntelliFireUserData(
|
||||
**load_json_object_fixture("user_data_3.json", DOMAIN)
|
||||
|
@ -165,7 +165,7 @@ def mock_cloud_interface() -> Generator[AsyncMock, None, None]:
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_local_interface() -> Generator[AsyncMock, None, None]:
|
||||
def mock_local_interface() -> Generator[AsyncMock]:
|
||||
"""Mock version of IntelliFireAPILocal."""
|
||||
poll_data = IntelliFirePollData(
|
||||
**load_json_object_fixture("intellifire/local_poll.json")
|
||||
|
@ -181,7 +181,7 @@ def mock_local_interface() -> Generator[AsyncMock, None, None]:
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_fp(mock_common_data_local) -> Generator[AsyncMock, None, None]:
|
||||
def mock_fp(mock_common_data_local) -> Generator[AsyncMock]:
|
||||
"""Mock fireplace."""
|
||||
|
||||
local_poll_data = IntelliFirePollData(
|
||||
|
|
|
@ -39,14 +39,14 @@ def platforms() -> list[Platform]:
|
|||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
async def mock_patch_platforms(platforms: list[str]) -> AsyncGenerator[None, None]:
|
||||
async def mock_patch_platforms(platforms: list[str]) -> AsyncGenerator[None]:
|
||||
"""Fixture to set up platforms for tests."""
|
||||
with patch(f"homeassistant.components.{DOMAIN}.PLATFORMS", platforms):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
||||
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||
"""Override async_setup_entry."""
|
||||
with patch(
|
||||
"homeassistant.components.smlight.async_setup_entry", return_value=True
|
||||
|
|
|
@ -25,7 +25,7 @@ CLIENT_ID = "1"
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_setup_entry() -> Generator[Mock, None, None]:
|
||||
def mock_setup_entry() -> Generator[Mock]:
|
||||
"""Patch setup entry."""
|
||||
with patch(
|
||||
"homeassistant.components.yale.async_setup_entry", return_value=True
|
||||
|
|
Loading…
Add table
Reference in a new issue