Debian Codegraph @

tests/conftest.py

raw
1 import logging
2 from collections.abc import Iterator
3 from unittest.mock import patch
4
5 import pytest
6 from blockbuster import BlockBuster, blockbuster_ctx
7
8 import bleak_retry_connector
9
10
11 @pytest.fixture(autouse=True)
12 def configure_test_logging(caplog):
13 caplog.set_level(logging.DEBUG)
14
15
16 @pytest.fixture(autouse=True)
17 def blockbuster() -> Iterator[BlockBuster]:
18 with blockbuster_ctx("bleak_retry_connector") as bb:
19 yield bb
20
21
22 @pytest.fixture()
23 def mock_linux():
24 with (
25 patch.object(bleak_retry_connector, "IS_LINUX", True),
26 patch.object(bleak_retry_connector.bluez, "IS_LINUX", True),
27 patch.object(bleak_retry_connector.bleak_manager, "IS_LINUX", True),
28 patch("bleak.backends.platform.system", return_value="Linux"),
29 ):
30 yield
31
32
33 @pytest.fixture()
34 def mock_macos():
35 with (
36 patch.object(bleak_retry_connector, "IS_LINUX", False),
37 patch.object(bleak_retry_connector.bluez, "IS_LINUX", False),
38 patch.object(bleak_retry_connector.bleak_manager, "IS_LINUX", False),
39 ):
40 yield