Skip to content

♻️ refactor(test): make aiobotocore patch an autouse session fixture#397

Merged
sodre merged 3 commits into
mainfrom
refactor/173-aiobotocore-patch-autouse
Feb 16, 2026
Merged

♻️ refactor(test): make aiobotocore patch an autouse session fixture#397
sodre merged 3 commits into
mainfrom
refactor/173-aiobotocore-patch-autouse

Conversation

@sodre

@sodre sodre commented Feb 16, 2026

Copy link
Copy Markdown
Member

Summary

  • Convert _patch_aiobotocore_response() from a manually-applied context manager (~90 call sites) to an autouse session-scoped fixture _patch_aiobotocore_for_moto in tests/fixtures/moto.py
  • Remove all manual with _patch_aiobotocore_response(): wrappers and their imports from unit tests, doctest conftest, and generated sync test files
  • Net deletion of ~200 lines of boilerplate across 10 test files

Test plan

  • All unit tests pass (uv run pytest tests/unit/)
  • All doctest tests pass (uv run pytest tests/doctest/)
  • Generated sync test files updated via hatch run generate-sync
  • CI passes (lint, type check, unit tests on Python 3.11 & 3.12)

Closes #173

🤖 Generated with Claude Code

…173)

Convert `_patch_aiobotocore_response()` from manual per-test usage to a
session-scoped autouse fixture in `tests/fixtures/moto.py`. This eliminates
~56 import+wrapper pairs across 8 test files (-204 net lines).

The patch is safe as autouse because it only transforms sync content to
async (a no-op when content is already async in integration/e2e tests).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sodre sodre added this to the v0.10.0 milestone Feb 16, 2026
@sodre sodre added the testing Test coverage label Feb 16, 2026
@codecov

codecov Bot commented Feb 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.88%. Comparing base (0edbb57) to head (467ddc6).
⚠️ Report is 4 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #397   +/-   ##
=======================================
  Coverage   91.88%   91.88%           
=======================================
  Files          33       33           
  Lines        7435     7435           
=======================================
  Hits         6832     6832           
  Misses        603      603           
Flag Coverage Δ
doctest 29.41% <ø> (ø)
e2e 42.36% <ø> (+0.64%) ⬆️
integration 51.36% <ø> (+0.53%) ⬆️
unit 91.62% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

sodre and others added 2 commits February 16, 2026 05:17
…173)

The session-scoped autouse fixture applied the moto patch globally,
including for LocalStack tests. For AioAWSResponse, wrapping _content
bytes in a Future causes double-indirection, breaking real HTTP calls.

Fix: integrate the patch into mock_dynamodb (and moto_env for doctests)
so it only activates when moto is mocking AWS, not when talking to
real LocalStack.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sodre sodre marked this pull request as ready for review February 16, 2026 11:57
@sodre sodre merged commit eca1c42 into main Feb 16, 2026
25 checks passed
@sodre sodre deleted the refactor/173-aiobotocore-patch-autouse branch February 16, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Test coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

♻️ Make aiobotocore patch an autouse session fixture

1 participant