Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test(google-adk): isolate instrumentor singleton overrides
  • Loading branch information
jabrailkhalil committed Oct 18, 2026
commit 9696d4e43ac0246bd6ef2272c99b754e5dc1d7f9
22 changes: 11 additions & 11 deletions python/tests/test_framework_google_adk.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ def test_instrumentation_dependencies(self):
deps = self.instrumentor.instrumentation_dependencies()
assert ("google-adk >= 1.2.1",) == deps

def test_instrument_basic(self):
def test_instrument_basic(self, monkeypatch):
"""Test basic instrumentation setup without complex patches."""
# Mock tracer setup
mock_tracer = Mock()
self.instrumentor._tracer = mock_tracer
monkeypatch.setattr(self.instrumentor, "_tracer", mock_tracer, raising=False)

# Mock the helper methods to avoid complex patching
self.instrumentor._patch_trace_call_llm = Mock()
self.instrumentor._patch_trace_tool_call = Mock()
self.instrumentor._disable_existing_tracers = Mock()
monkeypatch.setattr(self.instrumentor, "_patch_trace_call_llm", Mock())
monkeypatch.setattr(self.instrumentor, "_patch_trace_tool_call", Mock())
monkeypatch.setattr(self.instrumentor, "_disable_existing_tracers", Mock())

# Test that the helper methods would be called
self.instrumentor._patch_trace_call_llm()
Expand All @@ -71,13 +71,13 @@ def test_instrument_basic(self):
self.instrumentor._patch_trace_tool_call.assert_called_once()
self.instrumentor._disable_existing_tracers.assert_called_once()

def test_uninstrument(self):
def test_uninstrument(self, monkeypatch):
"""Test uninstrumentation."""
# Mock the cleanup methods
self.instrumentor._unpatch_trace_call_llm = Mock()
self.instrumentor._unpatch_trace_tool_call = Mock()
self.instrumentor._restore_existing_tracers = Mock()
self.instrumentor._originals = []
monkeypatch.setattr(self.instrumentor, "_unpatch_trace_call_llm", Mock())
monkeypatch.setattr(self.instrumentor, "_unpatch_trace_tool_call", Mock())
monkeypatch.setattr(self.instrumentor, "_restore_existing_tracers", Mock())
monkeypatch.setattr(self.instrumentor, "_originals", [], raising=False)

self.instrumentor._uninstrument()

Expand Down Expand Up @@ -461,4 +461,4 @@ def test_utility_functions_exception_handling(self):


if __name__ == "__main__":
pytest.main([__file__])
pytest.main([__file__])