♻️ refactor(test): make aiobotocore patch an autouse session fixture#397
Merged
Conversation
…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>
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…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>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
_patch_aiobotocore_response()from a manually-applied context manager (~90 call sites) to an autouse session-scoped fixture_patch_aiobotocore_for_motointests/fixtures/moto.pywith _patch_aiobotocore_response():wrappers and their imports from unit tests, doctest conftest, and generated sync test filesTest plan
uv run pytest tests/unit/)uv run pytest tests/doctest/)hatch run generate-syncCloses #173
🤖 Generated with Claude Code