Skip to content

Migrate tests from aioresponses to aiointercept - #803

Merged
joostlek merged 2 commits into
mainfrom
claude/affectionate-feynman-1aeh90
Sep 19, 2026
Merged

joostlek merged 2 commits into
mainfrom
claude/affectionate-feynman-1aeh90

Conversation

@joostlek

Copy link
Copy Markdown
Member

Description:

Migrate the test suite from aioresponses to aiointercept.

aioresponses builds aiohttp.ClientResponse objects by hand, which breaks on aiohttp 3.14 — that release added a required stream_writer keyword argument to ClientResponse.__init__, causing:

TypeError: ClientResponse.__init__() missing 1 required keyword-only argument: 'stream_writer'

aiointercept routes requests through a real aiohttp.web test server (so it never hand-builds response objects), supports aiohttp >= 3.13, and offers a largely aioresponses-compatible API.

This unblocks the aiohttp 3.14 renovate upgrade in #699 — with aioresponses removed, that PR's aiohttp bump can proceed.

Changes:

  • pyproject.toml dev deps: aioresponses==0.7.9aiointercept==0.1.10.
  • tests/conftest.py: the responses fixture is now async (aiointercept is an async context manager) and uses mock_external_urls=True so the clients' hardcoded absolute URLs are intercepted via DNS patching; dropped the now-unused Generator import.
  • Test modules: from aioresponses import aioresponsesfrom aiointercept import aiointercept, and every responses: aioresponses annotation updated accordingly.
  • tests/test_device.py: query-string params in the assert_called_with calls are now strings ("200"/"1") to match aiointercept's typed signature — this matches the string values actually sent on the wire.
  • uv.lock regenerated (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 ran pytest once with aiohttp==3.14.3 installed to confirm the unblock — all 112 tests pass there too.

Related issue (if applicable): N/A — unblocks #699

Checklist:

  • The code change is tested and works locally.
  • Local tests pass.
  • There is no commented out code in this PR.
  • Tests have been added/updated and code coverage percentage does not drop. No exclusions in .coveragerc allowed
  • README.MD updated (if necessary)

🤖 Generated with Claude Code

https://claude.ai/code/session_01Qfx1erxQ9XqnhGFe9RyYyc


Generated by Claude Code

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

codecov Bot commented Sep 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

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

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
@joostlek joostlek added the maintenance Generic maintenance tasks. label Sep 19, 2026 — with Claude
@sonarqubecloud

Copy link
Copy Markdown

@joostlek
joostlek merged commit 65f4e83 into main Sep 19, 2026
13 of 14 checks passed
@joostlek
joostlek deleted the claude/affectionate-feynman-1aeh90 branch September 19, 2026 13:46
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

maintenance Generic maintenance tasks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants