Skip to content

Commit 28559a5

Browse files
committed
fix(test): patch google.adk.models.lite_llm module-level imports for proper mocking
Change-Id: Ia5a211bb889e7f62986fa1a163ba47ad14a69f8d Co-developed-by: Cursor <[email protected]>
1 parent 7b2b091 commit 28559a5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/unittests/integration/test_integration.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,19 @@ async def fake_acompletion(*args, **kwargs):
6868
monkeypatch.setattr("litellm.completion", fake_completion)
6969
monkeypatch.setattr("litellm.acompletion", fake_acompletion)
7070

71+
# Also patch the module-level imports in google.adk.models.lite_llm
72+
# Google ADK imports acompletion at module level, so we need to patch
73+
# there as well to ensure the mock is used in all contexts
74+
try:
75+
import google.adk.models.lite_llm as lite_llm_module
76+
77+
monkeypatch.setattr(
78+
lite_llm_module, "acompletion", fake_acompletion
79+
)
80+
monkeypatch.setattr(lite_llm_module, "completion", fake_completion)
81+
except ImportError:
82+
pass # google.adk not installed, skip patching
83+
7184
def _setup_respx(self):
7285
"""Setup respx to intercept all httpx requests to mock base URL"""
7386

0 commit comments

Comments
 (0)