Skip to content

test: assert family/proto/flags on mDNS ResolveResults#97

Merged
bdraco merged 2 commits into
aio-libs:mainfrom
aiolibsbot:koan/resolve-result-socket-fields-coverage
May 21, 2026
Merged

test: assert family/proto/flags on mDNS ResolveResults#97
bdraco merged 2 commits into
aio-libs:mainfrom
aiolibsbot:koan/resolve-result-socket-fields-coverage

Conversation

@aiolibsbot
Copy link
Copy Markdown
Contributor

@aiolibsbot aiolibsbot commented May 21, 2026

What

Add a focused test file asserting the family, proto and flags fields of the ResolveResult entries produced by the mDNS resolvers.

Why

_to_resolve_result sets six fields, but the suite only ever asserted hostname/host/port. The family field is the subtle one: it is derived from the resolved address version (_IP_VERSION_TO_FAMILY[ip.version]), not from the family passed to resolve(). aiohttp opens its sockets based on this per-result family, so an AF_UNSPEC lookup returning a mix of IPv4/IPv6 addresses must tag each result individually. A refactor that echoed the query family (or hardcoded proto/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 from test_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-family family, proto == 0, flags == AI_NUMERICHOST | AI_NUMERICSERV.

Testing

python -m py_compile + ruff check pass. The mocks mirror the existing passing test_resolve_mdns_name_af_inet/unspec tests exactly, adding only assertions on the previously-unasserted fields. (The full pytest suite needs zeroconf/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

aiolibsbot and others added 2 commits May 21, 2026 00:03
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
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (5a01499) to head (294b369).
⚠️ Report is 4 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bdraco bdraco marked this pull request as ready for review May 21, 2026 18:54
@bdraco bdraco merged commit a185d60 into aio-libs:main May 21, 2026
26 checks passed
@aiolibsbot aiolibsbot deleted the koan/resolve-result-socket-fields-coverage branch May 21, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants