mirror of
https://github.com/home-assistant/core.git
synced 2025-11-07 09:59:30 +00:00
Enable ruff asyncio event loop blocking detection rules (#120799)
This commit is contained in:
@@ -44,7 +44,7 @@ async def test_protect_loop_debugger_sleep(caplog: pytest.LogCaptureFixture) ->
|
||||
return_value=frames,
|
||||
),
|
||||
):
|
||||
time.sleep(0)
|
||||
time.sleep(0) # noqa: ASYNC251
|
||||
assert "Detected blocking call inside the event loop" not in caplog.text
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ async def test_protect_loop_sleep() -> None:
|
||||
return_value=frames,
|
||||
),
|
||||
):
|
||||
time.sleep(0)
|
||||
time.sleep(0) # noqa: ASYNC251
|
||||
|
||||
|
||||
async def test_protect_loop_sleep_get_current_frame_raises() -> None:
|
||||
@@ -97,7 +97,7 @@ async def test_protect_loop_sleep_get_current_frame_raises() -> None:
|
||||
return_value=frames,
|
||||
),
|
||||
):
|
||||
time.sleep(0)
|
||||
time.sleep(0) # noqa: ASYNC251
|
||||
|
||||
|
||||
async def test_protect_loop_importlib_import_module_non_integration(
|
||||
@@ -211,7 +211,7 @@ async def test_protect_loop_open(caplog: pytest.LogCaptureFixture) -> None:
|
||||
block_async_io.enable()
|
||||
with (
|
||||
contextlib.suppress(FileNotFoundError),
|
||||
open("/proc/does_not_exist", encoding="utf8"),
|
||||
open("/proc/does_not_exist", encoding="utf8"), # noqa: ASYNC230
|
||||
):
|
||||
pass
|
||||
assert "Detected blocking call to open with args" not in caplog.text
|
||||
@@ -223,7 +223,7 @@ async def test_protect_open(caplog: pytest.LogCaptureFixture) -> None:
|
||||
block_async_io.enable()
|
||||
with (
|
||||
contextlib.suppress(FileNotFoundError),
|
||||
open("/config/data_not_exist", encoding="utf8"),
|
||||
open("/config/data_not_exist", encoding="utf8"), # noqa: ASYNC230
|
||||
):
|
||||
pass
|
||||
|
||||
@@ -253,7 +253,7 @@ async def test_protect_open_path(path: Any, caplog: pytest.LogCaptureFixture) ->
|
||||
"""Test opening a file by path in the event loop logs."""
|
||||
with patch.object(block_async_io, "_IN_TESTS", False):
|
||||
block_async_io.enable()
|
||||
with contextlib.suppress(FileNotFoundError), open(path, encoding="utf8"):
|
||||
with contextlib.suppress(FileNotFoundError), open(path, encoding="utf8"): # noqa: ASYNC230
|
||||
pass
|
||||
|
||||
assert "Detected blocking call to open with args" in caplog.text
|
||||
@@ -336,7 +336,7 @@ async def test_open_calls_ignored_in_tests(caplog: pytest.LogCaptureFixture) ->
|
||||
block_async_io.enable()
|
||||
with (
|
||||
contextlib.suppress(FileNotFoundError),
|
||||
open("/config/data_not_exist", encoding="utf8"),
|
||||
open("/config/data_not_exist", encoding="utf8"), # noqa: ASYNC230
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user