Fix flakey tests (#8914)

This commit is contained in:
J. Nick Koston 2025-05-26 23:20:14 -05:00 committed by GitHub
parent 4ac433fddb
commit caf9930ff9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 1 deletions

View File

@ -53,6 +53,8 @@ async def dashboard() -> DashboardTestHelper:
assert DASHBOARD.settings.on_ha_addon is True
assert DASHBOARD.settings.using_auth is False
task = asyncio.create_task(DASHBOARD.async_run())
# Wait for initial device loading to complete
await DASHBOARD.entries.async_request_update_entries()
client = AsyncHTTPClient()
io_loop = IOLoop(make_current=False)
yield DashboardTestHelper(io_loop, client, port)

View File

@ -5,6 +5,7 @@ from __future__ import annotations
import asyncio
from collections.abc import AsyncGenerator, Generator
from contextlib import AbstractAsyncContextManager, asynccontextmanager
import logging
from pathlib import Path
import platform
import signal
@ -40,6 +41,29 @@ from .types import (
)
@pytest.fixture(scope="module", autouse=True)
def enable_aioesphomeapi_debug_logging():
"""Enable debug logging for aioesphomeapi to help diagnose connection issues."""
# Get the aioesphomeapi logger
logger = logging.getLogger("aioesphomeapi")
# Save the original level
original_level = logger.level
# Set to DEBUG level
logger.setLevel(logging.DEBUG)
# Also ensure we have a handler that outputs to console
if not logger.handlers:
handler = logging.StreamHandler()
handler.setLevel(logging.DEBUG)
formatter = logging.Formatter(
"%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
handler.setFormatter(formatter)
logger.addHandler(handler)
yield
# Restore original level
logger.setLevel(original_level)
@pytest.fixture
def integration_test_dir() -> Generator[Path]:
"""Create a temporary directory for integration tests."""

View File

@ -2,7 +2,7 @@
# Network constants
DEFAULT_API_PORT = 6053
LOCALHOST = "localhost"
LOCALHOST = "127.0.0.1"
# Timeout constants
API_CONNECTION_TIMEOUT = 30.0 # seconds