Improve bluesound conftest function (#154828)

This commit is contained in:
Marc Mueller
2025-10-19 17:20:16 +02:00
committed by GitHub
parent 81572c6a84
commit d999dd05d1

View File

@@ -1,9 +1,11 @@
"""Common fixtures for the Bluesound tests."""
from __future__ import annotations
from collections.abc import AsyncGenerator, Generator
from dataclasses import dataclass
import ipaddress
from typing import Any
from typing import Any, Self
from unittest.mock import AsyncMock, patch
from pyblu import Input, Player, Preset, Status, SyncStatus
@@ -27,8 +29,8 @@ class PlayerMockData:
status_long_polling_mock: LongPollingMock[Status]
sync_status_long_polling_mock: LongPollingMock[SyncStatus]
@staticmethod
async def generate(host: str) -> "PlayerMockData":
@classmethod
async def generate(cls, host: str) -> Self:
"""Generate player mock data."""
host_ip = ipaddress.ip_address(host)
assert host_ip.version == 4
@@ -110,7 +112,7 @@ class PlayerMockData:
]
)
return PlayerMockData(
return cls(
host, player, status_long_polling_mock, sync_status_long_polling_mock
)