Skip to content

Commit 23c43d9

Browse files
committed
test: Suppress experimental feature warnings in unit tests
Unit tests instantiate many @experimental-decorated classes, flooding test output with [EXPERIMENTAL] UserWarning messages. Set ADK_SUPPRESS_EXPERIMENTAL_FEATURE_WARNINGS=true in the unittests conftest to silence them session-wide. The four *_no_parens / *_empty_parens decorator tests that assert the warning fires now delenv the suppress var first, matching the pattern already used by their sibling tests, so they remain valid under the new default. Change-Id: I589079da589eba76f799413e19287fd264986dd6
1 parent 6262f94 commit 23c43d9

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

tests/unittests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
'GOOGLE_CLOUD_PROJECT': 'fake_google_cloud_project',
2929
'GOOGLE_CLOUD_LOCATION': 'fake_google_cloud_location',
3030
'ADK_ALLOW_WIP_FEATURES': 'true',
31+
'ADK_SUPPRESS_EXPERIMENTAL_FEATURE_WARNINGS': 'true',
3132
}
3233

3334
ENV_SETUPS = {

tests/unittests/utils/test_feature_decorator.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,11 @@ def test_experimental_class_not_bypassed_for_false_env_var(monkeypatch):
306306
assert "[EXPERIMENTAL] ExperimentalClass:" in str(w[0].message)
307307

308308

309-
def test_experimental_class_no_parens_warns():
309+
def test_experimental_class_no_parens_warns(monkeypatch):
310310
"""Test that experimental class without parentheses shows default warning."""
311+
monkeypatch.delenv(
312+
"ADK_SUPPRESS_EXPERIMENTAL_FEATURE_WARNINGS", raising=False
313+
)
311314
with warnings.catch_warnings(record=True) as w:
312315
warnings.simplefilter("always")
313316

@@ -323,8 +326,11 @@ def test_experimental_class_no_parens_warns():
323326
)
324327

325328

326-
def test_experimental_class_empty_parens_warns():
329+
def test_experimental_class_empty_parens_warns(monkeypatch):
327330
"""Test that experimental class with empty parentheses shows default warning."""
331+
monkeypatch.delenv(
332+
"ADK_SUPPRESS_EXPERIMENTAL_FEATURE_WARNINGS", raising=False
333+
)
328334
with warnings.catch_warnings(record=True) as w:
329335
warnings.simplefilter("always")
330336

@@ -340,8 +346,11 @@ def test_experimental_class_empty_parens_warns():
340346
)
341347

342348

343-
def test_experimental_function_no_parens_warns():
349+
def test_experimental_function_no_parens_warns(monkeypatch):
344350
"""Test that experimental function without parentheses shows default warning."""
351+
monkeypatch.delenv(
352+
"ADK_SUPPRESS_EXPERIMENTAL_FEATURE_WARNINGS", raising=False
353+
)
345354
with warnings.catch_warnings(record=True) as w:
346355
warnings.simplefilter("always")
347356

@@ -356,8 +365,11 @@ def test_experimental_function_no_parens_warns():
356365
)
357366

358367

359-
def test_experimental_function_empty_parens_warns():
368+
def test_experimental_function_empty_parens_warns(monkeypatch):
360369
"""Test that experimental function with empty parentheses shows default warning."""
370+
monkeypatch.delenv(
371+
"ADK_SUPPRESS_EXPERIMENTAL_FEATURE_WARNINGS", raising=False
372+
)
361373
with warnings.catch_warnings(record=True) as w:
362374
warnings.simplefilter("always")
363375

0 commit comments

Comments
 (0)