mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Fail CI on lingering timers (part 2) (#89976)
* Fail CI on lingering timers (part 2) * Improve error message * Adjust tts
This commit is contained in:
parent
a272f8dfb2
commit
9e1a670e6e
@ -765,6 +765,7 @@ async def test_setup_component_test_with_cache_dir(
|
|||||||
await get_media_source_url(hass, calls[0].data[ATTR_MEDIA_CONTENT_ID])
|
await get_media_source_url(hass, calls[0].data[ATTR_MEDIA_CONTENT_ID])
|
||||||
== "/api/tts_proxy/42f18378fd4393d18c8dd11d03fa9563c1e54491_en_-_test.mp3"
|
== "/api/tts_proxy/42f18378fd4393d18c8dd11d03fa9563c1e54491_en_-_test.mp3"
|
||||||
)
|
)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
|
||||||
async def test_setup_component_test_with_error_on_get_tts(hass: HomeAssistant) -> None:
|
async def test_setup_component_test_with_error_on_get_tts(hass: HomeAssistant) -> None:
|
||||||
|
@ -47,7 +47,7 @@ from homeassistant.components.websocket_api.http import URL
|
|||||||
from homeassistant.config import YAML_CONFIG_FILE
|
from homeassistant.config import YAML_CONFIG_FILE
|
||||||
from homeassistant.config_entries import ConfigEntries, ConfigEntry
|
from homeassistant.config_entries import ConfigEntries, ConfigEntry
|
||||||
from homeassistant.const import HASSIO_USER_NAME
|
from homeassistant.const import HASSIO_USER_NAME
|
||||||
from homeassistant.core import CoreState, HomeAssistant
|
from homeassistant.core import CoreState, HassJob, HomeAssistant
|
||||||
from homeassistant.helpers import (
|
from homeassistant.helpers import (
|
||||||
area_registry as ar,
|
area_registry as ar,
|
||||||
config_entry_oauth2_flow,
|
config_entry_oauth2_flow,
|
||||||
@ -58,7 +58,7 @@ from homeassistant.helpers import (
|
|||||||
recorder as recorder_helper,
|
recorder as recorder_helper,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import BASE_PLATFORMS, async_setup_component
|
||||||
from homeassistant.util import dt as dt_util, location
|
from homeassistant.util import dt as dt_util, location
|
||||||
from homeassistant.util.json import json_loads
|
from homeassistant.util.json import json_loads
|
||||||
|
|
||||||
@ -273,8 +273,12 @@ def expected_lingering_timers() -> bool:
|
|||||||
This should be removed when all lingering timers have been cleaned up.
|
This should be removed when all lingering timers have been cleaned up.
|
||||||
"""
|
"""
|
||||||
current_test = os.getenv("PYTEST_CURRENT_TEST")
|
current_test = os.getenv("PYTEST_CURRENT_TEST")
|
||||||
if current_test and current_test.startswith("tests/components"):
|
if (
|
||||||
# As a starting point, we ignore components
|
current_test
|
||||||
|
and current_test.startswith("tests/components/")
|
||||||
|
and current_test.split("/")[2] not in BASE_PLATFORMS
|
||||||
|
):
|
||||||
|
# As a starting point, we ignore non-platform components
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -341,6 +345,8 @@ def verify_cleanup(
|
|||||||
if not handle.cancelled():
|
if not handle.cancelled():
|
||||||
if expected_lingering_timers:
|
if expected_lingering_timers:
|
||||||
_LOGGER.warning("Lingering timer after test %r", handle)
|
_LOGGER.warning("Lingering timer after test %r", handle)
|
||||||
|
elif handle._args and isinstance(job := handle._args[0], HassJob):
|
||||||
|
pytest.fail(f"Lingering timer after job {repr(job)}")
|
||||||
else:
|
else:
|
||||||
pytest.fail(f"Lingering timer after test {repr(handle)}")
|
pytest.fail(f"Lingering timer after test {repr(handle)}")
|
||||||
handle.cancel()
|
handle.cancel()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user