generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 192
fix: Rewrite environment tests to properly mock dependencies #19
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
Merged
Conversation
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
Mock os.environ for test_environment by using a fixture, eliminating the need to worry about the real os environment. Properly mock the get_user_input function by using a fixture as well and having environment import user_input as a module rather than importing the function directly. This is the more an important change as previously the user input wasn't being mocked in the tests - all tests were passing as the code paths didn't actually need "y".
Unshure
approved these changes
May 20, 2025
cagataycali
pushed a commit
to cagataycali/tools
that referenced
this pull request
May 20, 2025
…-agents#19) Mock os.environ for test_environment by using a fixture, eliminating the need to worry about the real os environment. Properly mock the get_user_input function by using a fixture as well and having environment import user_input as a module rather than importing the function directly. This is the more an important change as previously the user input wasn't being mocked in the tests - all tests were passing as the code paths didn't actually need "y". Co-authored-by: Mackenzie Zastrow <[email protected]>
Unshure
pushed a commit
to Unshure/tools
that referenced
this pull request
May 21, 2025
…-agents#19) Mock os.environ for test_environment by using a fixture, eliminating the need to worry about the real os environment. Properly mock the get_user_input function by using a fixture as well and having environment import user_input as a module rather than importing the function directly. This is the more an important change as previously the user input wasn't being mocked in the tests - all tests were passing as the code paths didn't actually need "y". Co-authored-by: Mackenzie Zastrow <[email protected]>
awsarron
pushed a commit
that referenced
this pull request
May 21, 2025
* Add GitHub actions to run tests on Windows/MacOS & handle failures on Windows (#18) Per #17 - Windows compatibility is currently unknown and all changes are currently only tested on Linux. For [parity with the SDK](https://github.com/strands-agents/sdk-python/blob/912e1104fd52e3da99767a644b90b22b7eb606de/.github/workflows/test-lint-pr.yml#L59), start running tests on MacOS & Windows. On MacOS all tests were already passing. On Windows I: - added [`tzdata` as a dependency](https://pypi.org/project/tzdata/) to make the `current_time` work - lazy loaded `session: PromptSession` in `get_user_input` to avoid import errors as part of the tests - updated [test_file_write.py](main...zastrowm:tools:windows_support#diff-a2998f18449d69766944a95d9058de448de22c38443a848876abaf22674df84a) to not use a permissions check, as the GitHub action runners seemingly run as super-admin and can write to the provided folders - disabled tests that were not trivial to fix - `test_shell`, `test_python_repl` - disabled some environment tests to better mock `get_user_input` - the two tests are failing on windows because of the lack of an interactive console. I'd like to fix these two tests to properly mock `get_user_input` but I'm going to break that out into a separate PR to keep this one more focused. To get linting to pass, I formatted the mem0 tool. * fix: improve tool interoperability and remove dependencies (#14) * chore: bump version from 0.1.0 to 0.1.1 * fix: improve tool interoperability and remove dependencies This commit enhances multiple tool components to better work together: - feat(think): inherit parent agent's traces and tools to maintain context - fix(load_tool): remove unnecessary hot_reload_tools dependency check - fix(use_llm): properly pass trace_attributes from parent agent to new instances - style(mem0_memory): improve code formatting and readability - test: update tests to match new implementation patterns * fix(slack): add missing trace_attributes to Agent initialization --------- Co-authored-by: Cagatay Cali <[email protected]> * docs: update memory examples to use agent.tool.X syntax (#22) * fix: Rewrite environment tests to properly mock dependencies (#19) Mock os.environ for test_environment by using a fixture, eliminating the need to worry about the real os environment. Properly mock the get_user_input function by using a fixture as well and having environment import user_input as a module rather than importing the function directly. This is the more an important change as previously the user input wasn't being mocked in the tests - all tests were passing as the code paths didn't actually need "y". Co-authored-by: Mackenzie Zastrow <[email protected]> * Update version to v0.1.2 (#23) --------- Co-authored-by: Mackenzie Zastrow <[email protected]> Co-authored-by: ./c² <[email protected]> Co-authored-by: Cagatay Cali <[email protected]> Co-authored-by: Mackenzie Zastrow <[email protected]>
cagataycali
added a commit
that referenced
this pull request
Jun 9, 2025
* chore: bump version from 0.1.0 to 0.1.1 * fix: improve tool interoperability and remove dependencies This commit enhances multiple tool components to better work together: - feat(think): inherit parent agent's traces and tools to maintain context - fix(load_tool): remove unnecessary hot_reload_tools dependency check - fix(use_llm): properly pass trace_attributes from parent agent to new instances - style(mem0_memory): improve code formatting and readability - test: update tests to match new implementation patterns * fix(slack): add missing trace_attributes to Agent initialization * docs(memory): update examples to use agent.tool.memory syntax * fix: Rewrite environment tests to properly mock dependencies (#19) Mock os.environ for test_environment by using a fixture, eliminating the need to worry about the real os environment. Properly mock the get_user_input function by using a fixture as well and having environment import user_input as a module rather than importing the function directly. This is the more an important change as previously the user input wasn't being mocked in the tests - all tests were passing as the code paths didn't actually need "y". Co-authored-by: Mackenzie Zastrow <[email protected]> * feat: add tool filtering to use_llm and think meta-tools - Add 'tools' parameter to use_llm and think functions for parent tool filtering - Implement tool registry filtering to prevent infinite recursion - Allow parent agents to specify subset of tools for child agents - Add comprehensive tests for tool filtering scenarios - Update documentation with tool filtering examples - Fix infinite recursion issue when use_llm calls use_llm or think calls think This enhancement allows better control over meta-tool capabilities and prevents recursive loops while maintaining backward compatibility. --------- Co-authored-by: Cagatay Cali <[email protected]> Co-authored-by: Mackenzie Zastrow <[email protected]> Co-authored-by: Mackenzie Zastrow <[email protected]> Co-authored-by: Strands Agent <[email protected]>
jimbrub
pushed a commit
to jimbrub/tools
that referenced
this pull request
Jun 23, 2025
) * chore: bump version from 0.1.0 to 0.1.1 * fix: improve tool interoperability and remove dependencies This commit enhances multiple tool components to better work together: - feat(think): inherit parent agent's traces and tools to maintain context - fix(load_tool): remove unnecessary hot_reload_tools dependency check - fix(use_llm): properly pass trace_attributes from parent agent to new instances - style(mem0_memory): improve code formatting and readability - test: update tests to match new implementation patterns * fix(slack): add missing trace_attributes to Agent initialization * docs(memory): update examples to use agent.tool.memory syntax * fix: Rewrite environment tests to properly mock dependencies (strands-agents#19) Mock os.environ for test_environment by using a fixture, eliminating the need to worry about the real os environment. Properly mock the get_user_input function by using a fixture as well and having environment import user_input as a module rather than importing the function directly. This is the more an important change as previously the user input wasn't being mocked in the tests - all tests were passing as the code paths didn't actually need "y". Co-authored-by: Mackenzie Zastrow <[email protected]> * feat: add tool filtering to use_llm and think meta-tools - Add 'tools' parameter to use_llm and think functions for parent tool filtering - Implement tool registry filtering to prevent infinite recursion - Allow parent agents to specify subset of tools for child agents - Add comprehensive tests for tool filtering scenarios - Update documentation with tool filtering examples - Fix infinite recursion issue when use_llm calls use_llm or think calls think This enhancement allows better control over meta-tool capabilities and prevents recursive loops while maintaining backward compatibility. --------- Co-authored-by: Cagatay Cali <[email protected]> Co-authored-by: Mackenzie Zastrow <[email protected]> Co-authored-by: Mackenzie Zastrow <[email protected]> Co-authored-by: Strands Agent <[email protected]>
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.
Description
Rewrite environment tests to properly mock dependencies
As a result:
Related Issues
get_user_inputis properly mockedInteresting Notes
I initially struggled to get mocking of get_user_input to work properly. After debugging for a while - I noticed that the
environmentmodule being imported into the test differed from the one that the tool was executing within. I am unclear why, but this explains why mocking ofget_user_inputwasn't working (I tried several different approaches). Something to consider if we see odd behavior mocking going forward.Type of Change
Testing
All of these
hatch fmt --linterhatch fmt --formatterhatch test --allChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.