From defa452aa19d48f38b0580527cdbd6ee46f8454a Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 8 Jul 2025 09:58:02 -0600 Subject: [PATCH] preen --- tests/integration/fixtures/runtime_stats.yaml | 4 +++- tests/integration/test_runtime_stats.py | 20 +++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/tests/integration/fixtures/runtime_stats.yaml b/tests/integration/fixtures/runtime_stats.yaml index 47ad30d95c..aad1c275fb 100644 --- a/tests/integration/fixtures/runtime_stats.yaml +++ b/tests/integration/fixtures/runtime_stats.yaml @@ -6,7 +6,9 @@ host: api: logger: - level: INFO + level: DEBUG + logs: + runtime_stats: INFO runtime_stats: log_interval: 1s diff --git a/tests/integration/test_runtime_stats.py b/tests/integration/test_runtime_stats.py index f0af04c2d8..e12c907f17 100644 --- a/tests/integration/test_runtime_stats.py +++ b/tests/integration/test_runtime_stats.py @@ -27,18 +27,18 @@ async def test_runtime_stats( # Track component stats component_stats_found = set() - # Patterns to match + # Patterns to match - need to handle ANSI color codes and timestamps + # The log format is: [HH:MM:SS][color codes][I][tag]: message total_stats_pattern = re.compile(r"Total stats \(since boot\):") - component_pattern = re.compile(r"^\s+(\w+):\s+count=(\d+),\s+avg=([\d.]+)ms") + # Match component names that may include dots (e.g., template.sensor) + component_pattern = re.compile( + r"^\[[^\]]+\].*?\s+([\w.]+):\s+count=(\d+),\s+avg=([\d.]+)ms" + ) def check_output(line: str) -> None: """Check log output for runtime stats messages.""" nonlocal stats_count - # Debug: print ALL lines to see what we're getting - if "[I]" in line or "[D]" in line or "[W]" in line or "[E]" in line: - print(f"LOG: {line}") - # Check for total stats line if total_stats_pattern.search(line): stats_count += 1 @@ -80,9 +80,9 @@ async def test_runtime_stats( ) # Verify we found stats for our components - assert "sensor" in component_stats_found, ( - f"Expected sensor stats, found: {component_stats_found}" + assert "template.sensor" in component_stats_found, ( + f"Expected template.sensor stats, found: {component_stats_found}" ) - assert "switch" in component_stats_found, ( - f"Expected switch stats, found: {component_stats_found}" + assert "template.switch" in component_stats_found, ( + f"Expected template.switch stats, found: {component_stats_found}" )