Import bluetooth in the executor to avoid blocking the event loop (#111596)
This commit is contained in:
parent
f622ddef47
commit
e25b097376
3 changed files with 29 additions and 3 deletions
|
@ -2,9 +2,33 @@
|
|||
|
||||
from unittest.mock import patch
|
||||
|
||||
from bleak_retry_connector import bleak_manager
|
||||
from dbus_fast.aio import message_bus
|
||||
import habluetooth.util as habluetooth_utils
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture(name="disable_bluez_manager_socket", autouse=True, scope="session")
|
||||
def disable_bluez_manager_socket():
|
||||
"""Mock the bluez manager socket."""
|
||||
with patch.object(bleak_manager, "get_global_bluez_manager_with_timeout"):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture(name="disable_dbus_socket", autouse=True, scope="session")
|
||||
def disable_dbus_socket():
|
||||
"""Mock the dbus message bus to avoid creating a socket."""
|
||||
with patch.object(message_bus, "MessageBus"):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture(name="disable_bluetooth_auto_recovery", autouse=True, scope="session")
|
||||
def disable_bluetooth_auto_recovery():
|
||||
"""Mock out auto recovery."""
|
||||
with patch.object(habluetooth_utils, "recover_adapter"):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture(name="operating_system_85")
|
||||
def mock_operating_system_85():
|
||||
"""Mock running Home Assistant Operating system 8.5."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue