mirror of
https://github.com/esphome/esphome.git
synced 2025-07-29 14:46:40 +00:00
Fix flakey tests (#8914)
This commit is contained in:
parent
4ac433fddb
commit
caf9930ff9
@ -53,6 +53,8 @@ async def dashboard() -> DashboardTestHelper:
|
|||||||
assert DASHBOARD.settings.on_ha_addon is True
|
assert DASHBOARD.settings.on_ha_addon is True
|
||||||
assert DASHBOARD.settings.using_auth is False
|
assert DASHBOARD.settings.using_auth is False
|
||||||
task = asyncio.create_task(DASHBOARD.async_run())
|
task = asyncio.create_task(DASHBOARD.async_run())
|
||||||
|
# Wait for initial device loading to complete
|
||||||
|
await DASHBOARD.entries.async_request_update_entries()
|
||||||
client = AsyncHTTPClient()
|
client = AsyncHTTPClient()
|
||||||
io_loop = IOLoop(make_current=False)
|
io_loop = IOLoop(make_current=False)
|
||||||
yield DashboardTestHelper(io_loop, client, port)
|
yield DashboardTestHelper(io_loop, client, port)
|
||||||
|
@ -5,6 +5,7 @@ from __future__ import annotations
|
|||||||
import asyncio
|
import asyncio
|
||||||
from collections.abc import AsyncGenerator, Generator
|
from collections.abc import AsyncGenerator, Generator
|
||||||
from contextlib import AbstractAsyncContextManager, asynccontextmanager
|
from contextlib import AbstractAsyncContextManager, asynccontextmanager
|
||||||
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import platform
|
import platform
|
||||||
import signal
|
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
|
@pytest.fixture
|
||||||
def integration_test_dir() -> Generator[Path]:
|
def integration_test_dir() -> Generator[Path]:
|
||||||
"""Create a temporary directory for integration tests."""
|
"""Create a temporary directory for integration tests."""
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Network constants
|
# Network constants
|
||||||
DEFAULT_API_PORT = 6053
|
DEFAULT_API_PORT = 6053
|
||||||
LOCALHOST = "localhost"
|
LOCALHOST = "127.0.0.1"
|
||||||
|
|
||||||
# Timeout constants
|
# Timeout constants
|
||||||
API_CONNECTION_TIMEOUT = 30.0 # seconds
|
API_CONNECTION_TIMEOUT = 30.0 # seconds
|
||||||
|
Loading…
x
Reference in New Issue
Block a user