Fix pytest-socket SocketBlockedError in test_init_setup_entry.py - #21
Merged
Merged
Conversation
manifest.json's dhcp dependency means every hass fixture in this file loads HA core's dhcp component. Its EVENT_HOMEASSISTANT_STARTED listener calls aiodhcpwatcher.async_init/async_start, which open a real AF_NETLINK socket via scapy -- irrelevant to what this file tests, and fatal under pytest-socket's sandbox (this is the pre-existing main-branch failure tracked across many CI runs: test_late_bound_tracker_watch_does_not_violate_thread_safety). Stub both calls so firing that event here only exercises this integration's own tracker-watch listener. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KmCpFs3Y4KhAjap7dSMNco
Owner
Author
|
CI confirms the fix: Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
docs/TEST_LEDGER.mdhas shownbackend-pytestred onmainfor several days now, always on the same single test:tests/python/setup/test_init_setup_entry.py::test_late_bound_tracker_watch_does_not_violate_thread_safety(pytest_socket.SocketBlockedError).manifest.jsondeclaresdhcpas a dependency, so everyhassfixture in this test file also loads HA core'sdhcpcomponent. That component's ownEVENT_HOMEASSISTANT_STARTEDlistener callsaiodhcpwatcher.async_init()and (viaDHCPWatcher.async_start)aiodhcpwatcher.async_start(), both of which open a realAF_NETLINKsocket viascapy— fatal underpytest-socket's sandbox, and unrelated to what this test file actually verifies (this integration's own late-bound tracker-watch listener).aiodhcpwatcherentry points in the file's existing_no_real_networkautouse fixture, so firingEVENT_HOMEASSISTANT_STARTEDin tests only exercises this integration's own listener, not HA core's real DHCP watcher.Pure test-infrastructure fix — no product code changed, no behavior change, so no KPF update needed per
AGENTS.md.Note: after this fix, the suite still shows 2 unrelated failures (
test_built_in_skills_seeded_on_first_load,test_built_ins_not_reseeded_after_user_deletes_one— a hardcoded built-in-skill count gone stale after the new "Daily Newspaper" skill was added). Out of scope for this PR; left untouched.Test plan
tests/python/setup/test_init_setup_entry.py— 9 passed, 0 errors (was: 1 error)Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01KmCpFs3Y4KhAjap7dSMNco
Generated by Claude Code