fix: make test_log_langfuse_v2_handles_null_usage_values more robust#17599
Merged
AlexsanderHamir merged 1 commit intomainfrom Dec 6, 2025
Merged
fix: make test_log_langfuse_v2_handles_null_usage_values more robust#17599AlexsanderHamir merged 1 commit intomainfrom
AlexsanderHamir merged 1 commit intomainfrom
Conversation
- Reset mock call counts at start of test to ensure clean state - Add span method to mock trace to handle log_provider_specific_information_as_span calls - Re-establish mock chain before test call to ensure fresh state - Add exception handling to catch and report errors during test execution - Add verification that trace was called before checking generation This should fix the flaky test that was failing intermittently with 'Expected generation to have been called once. Called 0 times.'
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
jquinter
added a commit
that referenced
this pull request
Feb 14, 2026
Fixes test_log_langfuse_v2_handles_null_usage_values flaky test failure by properly cleaning up sys.modules['langfuse'] in tearDown. Changes: - Store original langfuse module in setUp before mocking - Restore original or remove mock in tearDown to prevent state pollution - Remove invalid print_verbose parameter from log_event_on_langfuse Root Cause: The tearDown method was not cleaning up sys.modules['langfuse'] after each test, causing mock state to leak between tests. This caused intermittent failures in CI, especially when tests run in parallel or in different orders. Impact: This test has a long history of flakiness with multiple attempted fixes (#20475, #17599, #17594, #17591, #17588). The missing sys.modules cleanup was the underlying issue causing continued failures despite those patches. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
jquinter
added a commit
that referenced
this pull request
Feb 15, 2026
Fixes test_log_langfuse_v2_handles_null_usage_values flaky test failure by properly cleaning up sys.modules['langfuse'] in tearDown. Changes: - Store original langfuse module in setUp before mocking - Restore original or remove mock in tearDown to prevent state pollution - Remove invalid print_verbose parameter from log_event_on_langfuse Root Cause: The tearDown method was not cleaning up sys.modules['langfuse'] after each test, causing mock state to leak between tests. This caused intermittent failures in CI, especially when tests run in parallel or in different orders. Impact: This test has a long history of flakiness with multiple attempted fixes (#20475, #17599, #17594, #17591, #17588). The missing sys.modules cleanup was the underlying issue causing continued failures despite those patches. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
sameetn
pushed a commit
to sameetn/litellm
that referenced
this pull request
Feb 16, 2026
Fixes test_log_langfuse_v2_handles_null_usage_values flaky test failure by properly cleaning up sys.modules['langfuse'] in tearDown. Changes: - Store original langfuse module in setUp before mocking - Restore original or remove mock in tearDown to prevent state pollution - Remove invalid print_verbose parameter from log_event_on_langfuse Root Cause: The tearDown method was not cleaning up sys.modules['langfuse'] after each test, causing mock state to leak between tests. This caused intermittent failures in CI, especially when tests run in parallel or in different orders. Impact: This test has a long history of flakiness with multiple attempted fixes (BerriAI#20475, BerriAI#17599, BerriAI#17594, BerriAI#17591, BerriAI#17588). The missing sys.modules cleanup was the underlying issue causing continued failures despite those patches. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 task
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.
Title
fix: make test_log_langfuse_v2_handles_null_usage_values more robust
Relevant issues
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unitType
✅ Test
Changes
This should fix the flaky test that was failing intermittently with 'Expected generation to have been called once. Called 0 times.