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
2 changed files with 11 additions and 4 deletions
|
@ -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])
|
||||
== "/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:
|
||||
|
|
|
@ -47,7 +47,7 @@ from homeassistant.components.websocket_api.http import URL
|
|||
from homeassistant.config import YAML_CONFIG_FILE
|
||||
from homeassistant.config_entries import ConfigEntries, ConfigEntry
|
||||
from homeassistant.const import HASSIO_USER_NAME
|
||||
from homeassistant.core import CoreState, HomeAssistant
|
||||
from homeassistant.core import CoreState, HassJob, HomeAssistant
|
||||
from homeassistant.helpers import (
|
||||
area_registry as ar,
|
||||
config_entry_oauth2_flow,
|
||||
|
@ -58,7 +58,7 @@ from homeassistant.helpers import (
|
|||
recorder as recorder_helper,
|
||||
)
|
||||
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.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.
|
||||
"""
|
||||
current_test = os.getenv("PYTEST_CURRENT_TEST")
|
||||
if current_test and current_test.startswith("tests/components"):
|
||||
# As a starting point, we ignore components
|
||||
if (
|
||||
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 False
|
||||
|
||||
|
@ -341,6 +345,8 @@ def verify_cleanup(
|
|||
if not handle.cancelled():
|
||||
if expected_lingering_timers:
|
||||
_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:
|
||||
pytest.fail(f"Lingering timer after test {repr(handle)}")
|
||||
handle.cancel()
|
||||
|
|
Loading…
Add table
Reference in a new issue