fix(test): fix anthropic stream test mock missing get_final_message#2094
Merged
mkmeral merged 1 commit intostrands-agents:mainfrom Apr 8, 2026
Merged
Conversation
The test_stream_message_stop_no_pydantic_warnings test was using a raw async generator as the stream mock, which lacks get_final_message(). This caused an AttributeError on Python 3.14 after PR strands-agents#2047 introduced stream.get_final_message() in the Anthropic provider. Switch to generate_mock_stream_context helper which properly mocks the stream object with get_final_message support.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
|
/strands review |
|
Assessment: Approve Clean, minimal fix that correctly aligns this test with the established mocking pattern used by all other stream tests in the file. The switch from a raw No issues found — LGTM. |
gautamsirdeshmukh
approved these changes
Apr 8, 2026
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.
Problem
After #2047 introduced
stream.get_final_message()in the Anthropic provider, thetest_stream_message_stop_no_pydantic_warningsunit test started failing on Python 3.14 (failing run).The test was manually constructing an
async_generatoras the stream mock via theageneratorfixture, which lacks theget_final_message()method. On Python 3.14, theasync withcontext manager mock resolves differently, exposing this gap and causing:Solution
Switched the test to use the existing
generate_mock_stream_contexthelper, which properly creates a mock stream object withget_final_messagesupport. This is consistent with how all other stream tests in the file are structured.Related Issues
Type of Change
Bug fix (test)
Testing
generate_mock_stream_contexthelper used by all other stream tests in the file