Conversation
…_usage_values This test has failed repeatedly in CI with: 'Expected _add_prompt_to_generation_params to have been called once. Called 0 times.' Root cause: _add_prompt_to_generation_params is only called when _supports_prompt() returns True. Under cross-test state contamination in CI (parallel workers), langfuse_sdk_version can be in an unexpected state, causing _supports_prompt() to return False and silently skip the call (exception swallowed by the outer try/except). Fixes: - Use reset_mock(side_effect=True) so setUp's trace side_effect is cleared and the explicit return_value assignment actually takes effect - Patch _supports_prompt on the logger instance to always return True, making the _add_prompt_to_generation_params assertion independent of SDK version state Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR fixes a repeatedly flaky test (
Both fixes are minimal, well-targeted, and don't affect any production code. The test file is mock-only, consistent with the project rule requiring no real network calls in this test directory. Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| tests/test_litellm/integrations/test_langfuse.py | Two targeted fixes to prevent flaky test: (1) reset_mock(side_effect=True) clears setUp's side_effect so return_value assignments take effect, (2) patch.object(self.logger, "_supports_prompt", return_value=True) isolates the test from SDK version state contamination. Both changes are correct and well-scoped. |
Flowchart
flowchart TD
A[test_log_langfuse_v2_handles_null_usage_values] --> B[reset_mock - side_effect=True]
B --> C[Re-setup mock chain with return_value]
C --> D[patch _supports_prompt → True]
D --> E[_log_langfuse_v2 called]
E --> F{_supports_prompt?}
F -->|True - patched| G[_add_prompt_to_generation_params called]
G --> H[trace.generation called]
H --> I[Assert usage values converted None → 0]
I --> J[Assert _add_prompt_to_generation_params called once]
style B fill:#90EE90,stroke:#333
style D fill:#90EE90,stroke:#333
style F fill:#FFD700,stroke:#333
Last reviewed commit: 703f02b
Greptile SummaryThis PR fixes a repeatedly flaky test (
The changes are minimal, well-targeted, and correctly address the two root causes of the flaky test. Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| tests/test_litellm/integrations/test_langfuse.py | Two targeted fixes for flaky test: (1) reset_mock(side_effect=True) to properly clear setUp's _trace_side_effect so return_value assignments take effect, and (2) patch.object on _supports_prompt to decouple the _add_prompt_to_generation_params assertion from global SDK version state. Both changes are correct and well-scoped. |
Flowchart
flowchart TD
A["test_log_langfuse_v2_handles_null_usage_values"] --> B["reset_mock(side_effect=True)"]
B --> C["Clear setUp's _trace_side_effect"]
C --> D["Set return_value on trace mock"]
D --> E["patch _supports_prompt → True"]
E --> F["Call _log_langfuse_v2"]
F --> G{"_supports_prompt()"}
G -->|"True (patched)"| H["_add_prompt_to_generation_params called"]
H --> I["Assert generation called with correct usage values"]
I --> J["Assert _add_prompt_to_generation_params called once"]
G -->|"False (unpatched, flaky)"| K["_add_prompt_to_generation_params skipped"]
K --> L["❌ AssertionError: Called 0 times"]
Last reviewed commit: 703f02b
Summary
This test has repeatedly failed in CI (previously fixed in #17599, #20475, #21093) with:
_add_prompt_to_generation_paramsis only reached when_supports_prompt()returnsTruelangfuse_sdk_versioncan end up in an unexpected state_supports_prompt()then returnsFalse, silently skipping the call (the outertry/except Exceptionin_log_langfuse_v2swallows any exception)reset_mock()withoutside_effect=True, so setUp'strace.side_effectpersisted and overrode thereturn_valueset afterwardFixes:
reset_mock(side_effect=True)to clear setUp's side effects so the explicitreturn_valueassignments actually take effectpatch.object(self.logger, "_supports_prompt", return_value=True)to make the_add_prompt_to_generation_paramsassertion fully independent of SDK version state contaminationTest plan
poetry run pytest tests/test_litellm/integrations/test_langfuse.py::TestLangfuseUsageDetails -v— all 7 tests pass🤖 Generated with Claude Code