Use loader.async_suggest_report_issue in async util (#101516)
This commit is contained in:
parent
5d0c8947a1
commit
4e98d39106
2 changed files with 54 additions and 50 deletions
|
@ -48,7 +48,7 @@ async def test_check_loop_async() -> None:
|
|||
async def test_check_loop_async_integration(caplog: pytest.LogCaptureFixture) -> None:
|
||||
"""Test check_loop detects and raises when called from event loop from integration context."""
|
||||
with pytest.raises(RuntimeError), patch(
|
||||
"homeassistant.util.async_.extract_stack",
|
||||
"homeassistant.helpers.frame.extract_stack",
|
||||
return_value=[
|
||||
Mock(
|
||||
filename="/home/paulus/homeassistant/core.py",
|
||||
|
@ -69,10 +69,10 @@ async def test_check_loop_async_integration(caplog: pytest.LogCaptureFixture) ->
|
|||
):
|
||||
hasync.check_loop(banned_function)
|
||||
assert (
|
||||
"Detected blocking call to banned_function inside the event loop. This is "
|
||||
"causing stability issues. Please report issue for hue doing blocking calls at "
|
||||
"homeassistant/components/hue/light.py, line 23: self.light.is_on"
|
||||
in caplog.text
|
||||
"Detected blocking call to banned_function inside the event loop by integration"
|
||||
" 'hue' at homeassistant/components/hue/light.py, line 23: self.light.is_on, "
|
||||
"please create a bug report at https://github.com/home-assistant/core/issues?"
|
||||
"q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+hue%22" in caplog.text
|
||||
)
|
||||
|
||||
|
||||
|
@ -81,7 +81,7 @@ async def test_check_loop_async_integration_non_strict(
|
|||
) -> None:
|
||||
"""Test check_loop detects when called from event loop from integration context."""
|
||||
with patch(
|
||||
"homeassistant.util.async_.extract_stack",
|
||||
"homeassistant.helpers.frame.extract_stack",
|
||||
return_value=[
|
||||
Mock(
|
||||
filename="/home/paulus/homeassistant/core.py",
|
||||
|
@ -102,17 +102,17 @@ async def test_check_loop_async_integration_non_strict(
|
|||
):
|
||||
hasync.check_loop(banned_function, strict=False)
|
||||
assert (
|
||||
"Detected blocking call to banned_function inside the event loop. This is "
|
||||
"causing stability issues. Please report issue for hue doing blocking calls at "
|
||||
"homeassistant/components/hue/light.py, line 23: self.light.is_on"
|
||||
in caplog.text
|
||||
"Detected blocking call to banned_function inside the event loop by integration"
|
||||
" 'hue' at homeassistant/components/hue/light.py, line 23: self.light.is_on, "
|
||||
"please create a bug report at https://github.com/home-assistant/core/issues?"
|
||||
"q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+hue%22" in caplog.text
|
||||
)
|
||||
|
||||
|
||||
async def test_check_loop_async_custom(caplog: pytest.LogCaptureFixture) -> None:
|
||||
"""Test check_loop detects when called from event loop with custom component context."""
|
||||
with pytest.raises(RuntimeError), patch(
|
||||
"homeassistant.util.async_.extract_stack",
|
||||
"homeassistant.helpers.frame.extract_stack",
|
||||
return_value=[
|
||||
Mock(
|
||||
filename="/home/paulus/homeassistant/core.py",
|
||||
|
@ -133,10 +133,10 @@ async def test_check_loop_async_custom(caplog: pytest.LogCaptureFixture) -> None
|
|||
):
|
||||
hasync.check_loop(banned_function)
|
||||
assert (
|
||||
"Detected blocking call to banned_function inside the event loop. This is"
|
||||
" causing stability issues. Please report issue to the custom integration"
|
||||
" author for hue doing blocking calls at custom_components/hue/light.py, line"
|
||||
" 23: self.light.is_on"
|
||||
"Detected blocking call to banned_function inside the event loop by custom "
|
||||
"integration 'hue' at custom_components/hue/light.py, line 23: self.light.is_on"
|
||||
", please create a bug report at https://github.com/home-assistant/core/issues?"
|
||||
"q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+hue%22"
|
||||
) in caplog.text
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue