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.
()
| 75 | |
| 76 | |
| 77 | def 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 = """ |
| 84 | import sys |
| 85 | import google.adk |
| 86 | heavy_modules = ['google.cloud.aiplatform', 'sqlalchemy', 'a2a'] |
| 87 | loaded = [mod for mod in heavy_modules if mod in sys.modules] |
| 88 | print(','.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 | |
| 97 | def test_a2a_remote_agent_config_raises_importerror(): |