Fix homekit_controller tests to avoid global aid generation (#119852)
This commit is contained in:
parent
454ca0ce95
commit
e2276458ed
25 changed files with 792 additions and 344 deletions
|
@ -1,6 +1,6 @@
|
|||
"""HomeKit controller session fixtures."""
|
||||
|
||||
from collections.abc import Generator
|
||||
from collections.abc import Callable, Generator
|
||||
import datetime
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
|
@ -44,3 +44,16 @@ def hk_mock_async_zeroconf(mock_async_zeroconf: MagicMock) -> None:
|
|||
@pytest.fixture(autouse=True)
|
||||
def auto_mock_bluetooth(mock_bluetooth: None) -> None:
|
||||
"""Auto mock bluetooth."""
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def get_next_aid() -> Generator[Callable[[], int]]:
|
||||
"""Generate a function that returns increasing accessory ids."""
|
||||
id_counter = 0
|
||||
|
||||
def _get_id():
|
||||
nonlocal id_counter
|
||||
id_counter += 1
|
||||
return id_counter
|
||||
|
||||
return _get_id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue