Skip to content

Migrate tests to aiointercept and use aiohttp.encode_basic_auth - #538

Open
balloobbot wants to merge 2 commits into
automicus:v3.x.xfrom
balloobbot:encode-basic-auth
Open

Migrate tests to aiointercept and use aiohttp.encode_basic_auth#538
balloobbot wants to merge 2 commits into
automicus:v3.x.xfrom
balloobbot:encode-basic-auth

Conversation

@balloobbot

@balloobbot balloobbot commented Aug 22, 2026

Copy link
Copy Markdown

aiohttp.BasicAuth and the request auth parameter are deprecated and will be removed in aiohttp 4.0. Their replacement, aiohttp.encode_basic_auth(), landed in aiohttp 3.14.0, so the aiohttp floor moves to 3.14 and this migration becomes a non-event.

Reaching 3.14 first meant replacing aioresponses, which is why requirements-test.txt still capped aiohttp<3.14 (pnuckowski/aioresponses#288 is still unreleased). aiointercept is a near drop-in replacement that serves the same mocks from a real local aiohttp server and supports 3.14, so the cap is gone.

Two test-side notes:

  • aiointercept only produces ClientConnectionError, so the tests that inject a ClientResponseError or a ClientConnectorSSLError now patch the session instead of the mock. They cover the same branches.
  • Bare IP addresses are not intercepted, so conftest.py gains an autouse fixture routing them through aiohttp's resolver.

All 448 tests pass on aiohttp 3.14.3.

I'm a bot, asked by @balloob to fix this because the deprecation warning shows up in Home Assistant CI.

aiohttp.BasicAuth and the request `auth` parameter are deprecated and
will be removed in aiohttp 4.0.
@bdraco

bdraco commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

We should drop aioresponses and switch to aiointercept instead

aioresponses cannot mock aiohttp 3.14, which is what pinned the test
suite below it. aiointercept serves the same mocks from a real local
server and works on 3.14, so the aiohttp floor moves to 3.14 and the
hand-rolled Authorization header becomes aiohttp.encode_basic_auth().

Connection-layer failures aiointercept cannot emit (ClientResponseError,
ClientConnectorSSLError) are now injected by patching the session.
@balloobbot balloobbot changed the title Stop using deprecated aiohttp.BasicAuth Migrate tests to aiointercept and use aiohttp.encode_basic_auth Aug 23, 2026
@balloob

balloob commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Done

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.

3 participants