mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-11-09 02:49:43 +00:00
Finish out effort of adding and enabling blockbuster in tests (#5735)
* Finish out effort of adding and enabling blockbuster * Skip getting addon file size until securetar fixed * Fix test for devcontainer and blocking I/O * Fix docker fixture and load_config to post_init
This commit is contained in:
@@ -64,21 +64,16 @@ from .dbus_service_mocks.network_manager import NetworkManager as NetworkManager
|
||||
# pylint: disable=redefined-outer-name, protected-access
|
||||
|
||||
|
||||
# This commented out code is left in intentionally
|
||||
# Intent is to enable this for all tests at all times as an autouse fixture
|
||||
# Findings from PR were growing too big so disabling temporarily to create a checkpoint
|
||||
# @pytest.fixture(autouse=True)
|
||||
def blockbuster(request: pytest.FixtureRequest) -> BlockBuster:
|
||||
@pytest.fixture(autouse=True)
|
||||
def blockbuster() -> BlockBuster:
|
||||
"""Raise for blocking I/O in event loop."""
|
||||
# Excluded modules doesn't seem to stop test code from raising for blocking I/O
|
||||
# Defaulting to only scanning supervisor core code seems like the best we can do easily
|
||||
# Added a parameter so we could potentially go module by module in test and eliminate blocking I/O
|
||||
# Then we could tell it to scan everything by default. That will require more follow-up work
|
||||
# Only scanning supervisor code for now as that's our primary interest
|
||||
# This will still raise for tests that call utilities in supervisor code that block
|
||||
# But it will ignore calls to libraries and such that do blocking I/O directly from tests
|
||||
# Removing that would be nice but a todo for the future
|
||||
|
||||
# pylint: disable-next=contextmanager-generator-missing-cleanup
|
||||
with blockbuster_ctx(
|
||||
scanned_modules=getattr(request, "param", ["supervisor"])
|
||||
) as bb:
|
||||
with blockbuster_ctx(scanned_modules=["supervisor"]) as bb:
|
||||
yield bb
|
||||
|
||||
|
||||
@@ -118,7 +113,7 @@ async def docker() -> DockerAPI:
|
||||
),
|
||||
patch("supervisor.docker.manager.DockerAPI.unload"),
|
||||
):
|
||||
docker_obj = DockerAPI(MagicMock())
|
||||
docker_obj = await DockerAPI(MagicMock()).post_init()
|
||||
docker_obj.config._data = {"registries": {}}
|
||||
with patch("supervisor.docker.monitor.DockerMonitor.load"):
|
||||
await docker_obj.load()
|
||||
|
||||
Reference in New Issue
Block a user