Skip to content

Commit 7a366a2

Browse files
committed
test: make characterization snapshot deterministic across machines
The spool sensor computes its 'used_percentage' attribute only in _handle_coordinator_update(), not in the constructor. Whether that handler had fired by the time the state snapshot was captured depended on coordinator-update timing, so the attribute was present locally but absent on CI — making test_all_entities_snapshot flaky (CI failure on HA 2026.5.4 with otherwise-identical package versions). Force one coordinator refresh in the setup_integration fixture after setup so every entity's update handler runs deterministically before the snapshot is taken. The committed snapshot is unchanged (it already reflected the post-update state).
1 parent b7058f8 commit 7a366a2

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

tests/conftest.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,18 @@ async def setup_integration(
198198
config_entry: MockConfigEntry,
199199
mock_spoolman_api: aioresponses,
200200
) -> MockConfigEntry:
201-
"""Boot the integration end-to-end against the mocked API."""
201+
"""Boot the integration end-to-end against the mocked API.
202+
203+
After setup we force one coordinator refresh so every entity's
204+
``_handle_coordinator_update`` runs deterministically. Some attributes
205+
(e.g. the spool sensor's ``used_percentage``) are only computed in that
206+
handler, not in the constructor; without this, whether they appear in a
207+
state snapshot depends on update timing and diverges between machines
208+
(local vs. CI), making the characterization snapshot flaky.
209+
"""
202210
config_entry.add_to_hass(hass)
203211
assert await hass.config_entries.async_setup(config_entry.entry_id)
204212
await hass.async_block_till_done()
213+
await config_entry.runtime_data.coordinator.async_refresh()
214+
await hass.async_block_till_done()
205215
return config_entry

0 commit comments

Comments
 (0)