Migrate tests from aioresponses to aiointercept - #803
Merged
Merged
Conversation
aioresponses builds aiohttp.ClientResponse objects by hand, which breaks on aiohttp 3.14 (it added a required stream_writer kwarg to ClientResponse.__init__). Replace it with aiointercept, which routes requests through a real aiohttp.web test server and supports aiohttp >= 3.13, unblocking the aiohttp 3.14 upgrade. The responses fixture becomes async (aiointercept is an async context manager) and uses mock_external_urls=True so the clients' hardcoded absolute URLs are intercepted via DNS patching. Query-string params in the assert_called_with calls are now strings to match aiointercept's typed signature. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qfx1erxQ9XqnhGFe9RyYyc
Codecov Report✅ All modified and coverable lines are covered by tests. 🚀 New features to boost your workflow:
|
The reworked params assertions in test_fetching_multiple_pages tripped `ruff format --check` in CI. Run ruff format to fix the whitespace. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qfx1erxQ9XqnhGFe9RyYyc
|
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.



Description:
Migrate the test suite from
aioresponsestoaiointercept.aioresponsesbuildsaiohttp.ClientResponseobjects by hand, which breaks on aiohttp 3.14 — that release added a requiredstream_writerkeyword argument toClientResponse.__init__, causing:aiointerceptroutes requests through a realaiohttp.webtest server (so it never hand-builds response objects), supports aiohttp >= 3.13, and offers a largelyaioresponses-compatible API.This unblocks the aiohttp 3.14 renovate upgrade in #699 — with
aioresponsesremoved, that PR's aiohttp bump can proceed.Changes:
pyproject.tomldev deps:aioresponses==0.7.9→aiointercept==0.1.10.tests/conftest.py: theresponsesfixture is nowasync(aiointercept is an async context manager) and usesmock_external_urls=Trueso the clients' hardcoded absolute URLs are intercepted via DNS patching; dropped the now-unusedGeneratorimport.from aioresponses import aioresponses→from aiointercept import aiointercept, and everyresponses: aioresponsesannotation updated accordingly.tests/test_device.py: query-stringparamsin theassert_called_withcalls are now strings ("200"/"1") to match aiointercept's typed signature — this matches the string values actually sent on the wire.uv.lockregenerated (aiohttp stays at 3.13.5; the bump belongs to ⬆️ Update dependency aiohttp to v3.14.3 [SECURITY] #699).Validation (all pass):
ruff check,mypy src/ tests/,pytest(112 passed, coverage unchanged at 95%). Also ranpytestonce withaiohttp==3.14.3installed to confirm the unblock — all 112 tests pass there too.Related issue (if applicable): N/A — unblocks #699
Checklist:
.coveragercallowedREADME.MDupdated (if necessary)🤖 Generated with Claude Code
https://claude.ai/code/session_01Qfx1erxQ9XqnhGFe9RyYyc
Generated by Claude Code