Skip to content

Commit 6720f2b

Browse files
committed
test(o11y): add coverage for environment overrides and fallback
1 parent ebbe3c6 commit 6720f2b

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

packages/google-api-core/tests/unit/observability/test_options.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,30 @@ def test_get_env_bool(monkeypatch):
6969
assert _get_env_bool("TEST_VAR") is None
7070

7171

72+
def test_set_test_env_override_clear_specific():
73+
"""Verify that setting an override to None clears that specific override.
74+
75+
This is important to ensure tests can reset individual environment overrides
76+
without affecting other overrides that might be set for other tests running
77+
concurrently or subsequently.
78+
"""
79+
set_test_env_override("TEST_CLEAR", True)
80+
assert _get_env_bool("TEST_CLEAR") is True
81+
set_test_env_override("TEST_CLEAR", None)
82+
assert _get_env_bool("TEST_CLEAR") is None
83+
84+
85+
def test_get_env_bool_with_dev_fallback_other_prefix(monkeypatch):
86+
"""Verify that environment variables without the 'GOOGLE_CLOUD_' prefix fall back directly.
87+
88+
This is important to ensure that generic or non-GCP environment variables
89+
are handled correctly by the fallback logic without triggering GCP-specific
90+
replacement logic.
91+
"""
92+
monkeypatch.setenv("OTHER_PREFIX_VAR", "true")
93+
assert options._get_env_bool_with_dev_fallback("OTHER_PREFIX_VAR") is True
94+
95+
7296
@pytest.mark.parametrize(
7397
"signal_type, env_vars, client_options, default_val, expected",
7498
[

0 commit comments

Comments
 (0)