MCPcopy Create free account
hub / github.com/google/adk-python / test_no_eager_imports

Function test_no_eager_imports

tests/unittests/test_optional_dependencies.py:77–94  ·  view source on GitHub ↗

Verify that importing google.adk does not eagerly load heavy optional deps. Runs in the current environment but in a fresh subprocess, ensuring it only checks the import side-effects without modifying the environment.

()

Source from the content-addressed store, hash-verified

75
76
77def test_no_eager_imports():
78 """Verify that importing google.adk does not eagerly load heavy optional deps.
79
80 Runs in the current environment but in a fresh subprocess, ensuring it
81 only checks the import side-effects without modifying the environment.
82 """
83 code = """
84import sys
85import google.adk
86heavy_modules = ['google.cloud.aiplatform', 'sqlalchemy', 'a2a']
87loaded = [mod for mod in heavy_modules if mod in sys.modules]
88print(','.join(loaded))
89"""
90 result = subprocess.run(
91 [sys.executable, "-c", code], capture_output=True, text=True, check=True
92 )
93 loaded_modules = result.stdout.strip()
94 assert loaded_modules == "", f"Heavy modules loaded eagerly: {loaded_modules}"
95
96
97def test_a2a_remote_agent_config_raises_importerror():

Callers

nothing calls this directly

Calls 2

stripMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected