test: Suppress experimental feature warnings in unit tests

Merge https://github.com/google/adk-python/pull/6087

## Summary

- Unit tests instantiate many `@experimental`-decorated classes, flooding test output with `[EXPERIMENTAL]` `UserWarning` messages.
- Set `ADK_SUPPRESS_EXPERIMENTAL_FEATURE_WARNINGS=true` in `tests/unittests/conftest.py` (alongside the existing `ADK_ALLOW_WIP_FEATURES`) to silence them session-wide.
- The four `*_no_parens` / `*_empty_parens` decorator tests that assert the warning fires now `monkeypatch.delenv` the suppress var first, matching the pattern already used by their sibling tests, so they remain valid under the new default.

## Test plan

- [x] `uv run pytest tests/unittests/utils/test_feature_decorator.py tests/unittests/features/test_feature_decorator.py` passes
- [x] Verified a real `@experimental` class (`InMemoryCredentialService`) emits 0 `[EXPERIMENTAL]` warnings with the var set, 2 without

Co-authored-by: Wei Sun (Jack) <weisun@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/6087 from google:test/suppress-experimental-warnings 23c43d9188fe33529b41d08325eb1c41ac5dddd6
PiperOrigin-RevId: 930824931
This commit is contained in:
Wei (Jack) Sun
2026-06-11 17:27:14 -07:00
committed by Copybara-Service
parent 6262f9415d
commit 87538d2350
2 changed files with 17 additions and 4 deletions
+1
View File
@@ -28,6 +28,7 @@ _ENV_VARS = {
'GOOGLE_CLOUD_PROJECT': 'fake_google_cloud_project',
'GOOGLE_CLOUD_LOCATION': 'fake_google_cloud_location',
'ADK_ALLOW_WIP_FEATURES': 'true',
'ADK_SUPPRESS_EXPERIMENTAL_FEATURE_WARNINGS': 'true',
}
ENV_SETUPS = {
@@ -306,8 +306,11 @@ def test_experimental_class_not_bypassed_for_false_env_var(monkeypatch):
assert "[EXPERIMENTAL] ExperimentalClass:" in str(w[0].message)
def test_experimental_class_no_parens_warns():
def test_experimental_class_no_parens_warns(monkeypatch):
"""Test that experimental class without parentheses shows default warning."""
monkeypatch.delenv(
"ADK_SUPPRESS_EXPERIMENTAL_FEATURE_WARNINGS", raising=False
)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
@@ -323,8 +326,11 @@ def test_experimental_class_no_parens_warns():
)
def test_experimental_class_empty_parens_warns():
def test_experimental_class_empty_parens_warns(monkeypatch):
"""Test that experimental class with empty parentheses shows default warning."""
monkeypatch.delenv(
"ADK_SUPPRESS_EXPERIMENTAL_FEATURE_WARNINGS", raising=False
)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
@@ -340,8 +346,11 @@ def test_experimental_class_empty_parens_warns():
)
def test_experimental_function_no_parens_warns():
def test_experimental_function_no_parens_warns(monkeypatch):
"""Test that experimental function without parentheses shows default warning."""
monkeypatch.delenv(
"ADK_SUPPRESS_EXPERIMENTAL_FEATURE_WARNINGS", raising=False
)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
@@ -356,8 +365,11 @@ def test_experimental_function_no_parens_warns():
)
def test_experimental_function_empty_parens_warns():
def test_experimental_function_empty_parens_warns(monkeypatch):
"""Test that experimental function with empty parentheses shows default warning."""
monkeypatch.delenv(
"ADK_SUPPRESS_EXPERIMENTAL_FEATURE_WARNINGS", raising=False
)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")