test: assert family/proto/flags on mDNS ResolveResults#97
Merged
bdraco merged 2 commits intoMay 21, 2026
Merged
Conversation
The conversion from a zeroconf address to an aiohttp ResolveResult sets family, proto and flags in addition to hostname/host/port, but none of those three fields were asserted anywhere. The family in particular is derived from the resolved address version rather than the requested query family, so an AF_UNSPEC lookup returning mixed IPv4/IPv6 addresses must tag each result individually. A new test file locks in that contract. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #97 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 6 7 +1
Lines 521 566 +45
Branches 23 23
=========================================
+ Hits 521 566 +45 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
bdraco
approved these changes
May 21, 2026
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.
What
Add a focused test file asserting the
family,protoandflagsfields of theResolveResultentries produced by the mDNS resolvers.Why
_to_resolve_resultsets six fields, but the suite only ever assertedhostname/host/port. Thefamilyfield is the subtle one: it is derived from the resolved address version (_IP_VERSION_TO_FAMILY[ip.version]), not from the family passed toresolve(). aiohttp opens its sockets based on this per-resultfamily, so anAF_UNSPEClookup returning a mix of IPv4/IPv6 addresses must tag each result individually. A refactor that echoed the query family (or hardcodedproto/flags) would silently misroute connections while all existing tests still passed.How
New file
tests/test_resolve_result_fields.py(kept separate to avoid churn against in-flight test PRs). It reuses the established patchable-resolver pattern fromtest_impl.py:test_unspec_result_family_follows_address_version— AF_UNSPEC + mixed v4/v6 →[AF_INET, AF_INET6].test_ipv4_result_socket_fields/test_ipv6_result_socket_fields— per-familyfamily,proto == 0,flags == AI_NUMERICHOST | AI_NUMERICSERV.Testing
python -m py_compile+ruff checkpass. The mocks mirror the existing passingtest_resolve_mdns_name_af_inet/unspectests exactly, adding only assertions on the previously-unasserted fields. (The full pytest suite needszeroconf/aiodns, which aren't installable in this environment — CI exercises it.)🤖 Generated with Claude Code
Quality Report
Changes: 2 files changed, 135 insertions(+)
Code scan: clean
Tests: failed (FAILED)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline