-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
litellm_fix_mapped_tests_core: fix test isolation and mock injection issues #20208
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
Closed
shin-bot-litellm
wants to merge
1
commit into
main
from
fix/mapped-tests-core-scientific-notation-and-mocks
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2282,8 +2282,19 @@ def test_register_model_with_scientific_notation(): | |||||
| """ | ||||||
| Test that the register_model function can handle scientific notation in the model name. | ||||||
| """ | ||||||
| # Use a unique model name to avoid conflicts with other tests | ||||||
| test_model_name = "test-scientific-notation-model-unique-12345" | ||||||
|
|
||||||
| # Clean up any pre-existing entry and clear caches | ||||||
| if test_model_name in litellm.model_cost: | ||||||
| del litellm.model_cost[test_model_name] | ||||||
|
|
||||||
| # Clear LRU caches that might have stale data | ||||||
| from litellm.utils import get_model_info, _cached_get_model_info_helper, _invalidate_model_cost_lowercase_map | ||||||
|
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.
Suggested change
Prompt To Fix With AIThis is a comment left during a code review.
Path: tests/test_litellm/test_utils.py
Line: 2293:2293
Comment:
`get_model_info` and `_cached_get_model_info_helper` are imported but never used
```suggestion
from litellm.utils import _invalidate_model_cost_lowercase_map
```
How can I resolve this? If you propose a fix, please make it concise. |
||||||
| _invalidate_model_cost_lowercase_map() | ||||||
|
|
||||||
| model_cost_dict = { | ||||||
| "my-custom-model": { | ||||||
| test_model_name: { | ||||||
| "max_tokens": 8192, | ||||||
| "input_cost_per_token": "3e-07", | ||||||
| "output_cost_per_token": "6e-07", | ||||||
|
|
@@ -2294,12 +2305,17 @@ def test_register_model_with_scientific_notation(): | |||||
|
|
||||||
| litellm.register_model(model_cost_dict) | ||||||
|
|
||||||
| registered_model = litellm.model_cost["my-custom-model"] | ||||||
| registered_model = litellm.model_cost[test_model_name] | ||||||
| print(registered_model) | ||||||
| assert registered_model["input_cost_per_token"] == 3e-07 | ||||||
| assert registered_model["output_cost_per_token"] == 6e-07 | ||||||
| assert registered_model["litellm_provider"] == "openai" | ||||||
| assert registered_model["mode"] == "chat" | ||||||
|
|
||||||
| # Clean up after test | ||||||
| if test_model_name in litellm.model_cost: | ||||||
| del litellm.model_cost[test_model_name] | ||||||
| _invalidate_model_cost_lowercase_map() | ||||||
|
|
||||||
|
|
||||||
| def test_reasoning_content_preserved_in_text_completion_wrapper(): | ||||||
|
|
||||||
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
Oops, something went wrong.
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.
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.
inconsistent with the async test approach at line 215 which patches
litellm.google_genai.adapters.handler.litellm. Consider using the same direct patching approach for consistencyNote: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI