Switch test suite from aioresponses to aiointercept#347
Conversation
aioresponses 0.7.8 breaks under aiohttp 3.14; ClientResponse now requires a stream_writer argument so every mocked request raised a TypeError. aiointercept routes requests through a real aiohttp test server instead of monkey patching internals, so it keeps working across aiohttp releases. The mock_external_urls option keeps the SUPERVISOR_URL host intercepted, so the existing call sites need no changes. The client side request timeout is not visible through a real round trip, so it is captured with a fixture and asserted via a shared helper. Also bumps the pinned aiohttp to 3.14.1.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #347 +/- ##
=======================================
Coverage 99.56% 99.56%
=======================================
Files 34 34
Lines 1381 1381
=======================================
Hits 1375 1375
Misses 6 6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@esphbot review |
|
|
|
|
PR Review — Switch test suite from aioresponses to aiointerceptClean, test-only migration from aioresponses to aiointercept. Merge-ready.
Checklist
Automated review by Kōan (Claude) |
MartinHjelmare
left a comment
There was a problem hiding this comment.
Looks and sounds good. @agners do you agree?
agners
left a comment
There was a problem hiding this comment.
aiointercept seems to be a step towards integration tests. Personally, I like unit tests to be just unit tests with as little system dependencies and not doing any I/O etc.
But relying on testing dependencies which hold back the main dependency upgrades is arguably worse. With aiointercept being the recommended unit test suite for aiohttp client requests, sure let's go with it!
Proposed Changes
Switch the test suite from aioresponses to aiointercept.
aioresponses mocks by calling the ClientResponse constructor directly, but that constructor is not public; the aiohttp docs are explicit that users never construct ClientResponse, they only get it from API calls. By replicating that signature aioresponses ties itself to an aiohttp internal that changes as needed, so it breaks on nearly every minor bump. The latest case is aiohttp 3.14, where ClientResponse gained a required stream_writer argument and every mocked request now raises a TypeError. aiohttp maintainers have said they will not keep patching aioresponses for this, and recommend migrating; see aio-libs/aiohttp#12815 and the discussion at aio-libs/discussions/45.
aiointercept routes requests through a real aiohttp test server instead of monkey patching internals, so it does not depend on private signatures and keeps working across aiohttp releases. The mock_external_urls option keeps the SUPERVISOR_URL host intercepted, so the call sites are unchanged apart from the rename. The client side request timeout is not visible through a real round trip, so it is captured with a small fixture and asserted through a shared helper. The aiohttp pin is left as is so dependabot can bump it in #344.
Related Issues
Unblocks #344, works around aio-libs/aiohttp#12815