-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: issue 3772 #3773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: issue 3772 #3773
Changes from all commits
86c8f0c
ffc7b8e
4bddf57
f6c6689
6286b86
452611c
cd9795d
5fd7d38
0fde4ac
d89a0cb
ef1dcab
5382a9a
2ed38f5
faa12be
a82d190
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |||||
| import tempfile | ||||||
| from unittest.mock import AsyncMock | ||||||
| from unittest.mock import create_autospec | ||||||
| from unittest.mock import MagicMock | ||||||
| from unittest.mock import Mock | ||||||
| from unittest.mock import patch | ||||||
|
|
||||||
|
|
@@ -1002,7 +1003,7 @@ async def test_handle_a2a_response_with_task_submitted_and_no_update(self): | |||||
| mock_a2a_task, | ||||||
| self.agent.name, | ||||||
| self.mock_context, | ||||||
| self.mock_a2a_part_converter, | ||||||
| self.agent._a2a_part_converter, | ||||||
| ) | ||||||
| # Check the parts are updated as Thought | ||||||
| assert result.content.parts[0].thought is True | ||||||
|
|
@@ -1770,7 +1771,7 @@ async def test_run_async_impl_successful_request(self): | |||||
| ) # Tuple with parts and context_id | ||||||
|
|
||||||
| # Mock A2A client | ||||||
| mock_a2a_client = create_autospec(spec=A2AClient, instance=True) | ||||||
| mock_a2a_client = MagicMock(spec=A2AClient) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing from
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test failed if I use create_autospec |
||||||
| mock_response = Mock() | ||||||
| mock_send_message = AsyncMock() | ||||||
| mock_send_message.__aiter__.return_value = [mock_response] | ||||||
|
|
@@ -1909,7 +1910,7 @@ async def test_run_async_impl_with_meta_provider(self): | |||||
| ) # Tuple with parts and context_id | ||||||
|
|
||||||
| # Mock A2A client | ||||||
| mock_a2a_client = create_autospec(spec=A2AClient, instance=True) | ||||||
| mock_a2a_client = MagicMock(spec=A2AClient) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing from
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test failed if I use create_autospec |
||||||
| mock_response = Mock() | ||||||
| mock_send_message = AsyncMock() | ||||||
| mock_send_message.__aiter__.return_value = [mock_response] | ||||||
|
|
@@ -2046,7 +2047,7 @@ async def test_run_async_impl_successful_request(self): | |||||
| ) # Tuple with parts and context_id | ||||||
|
|
||||||
| # Mock A2A client | ||||||
| mock_a2a_client = create_autospec(spec=A2AClient, instance=True) | ||||||
| mock_a2a_client = MagicMock(spec=A2AClient) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing from
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test failed if I use create_autospec |
||||||
| mock_response = Mock() | ||||||
| mock_send_message = AsyncMock() | ||||||
| mock_send_message.__aiter__.return_value = [mock_response] | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While
MagicMockis functional,create_autospecprovides stronger type checking and ensures that the mock adheres more closely to theA2AClientinterface. This can help catch potential API mismatches or typos during testing, leading to more robust tests. Consider usingcreate_autospecfor better test safety.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test failed if I use create_autospec