From cf118671598f2e656b750c13f7750fa48df31cec Mon Sep 17 00:00:00 2001 From: Julio Quinteros Pro Date: Sun, 15 Feb 2026 19:16:46 -0300 Subject: [PATCH 1/2] fix(test): add environment cleanup for Vertex AI GPT-OSS tests Add autouse pytest fixture to clear Google/Vertex AI environment variables before each test, preventing authentication errors in CI. Previous tests may set GOOGLE_APPLICATION_CREDENTIALS or other Vertex environment variables and not clean them up, causing this test to attempt real Google authentication instead of using mocks. This fix: - Adds clean_vertex_env fixture with autouse=True - Saves and clears Google/Vertex env vars before each test - Restores them after each test - Prevents "AuthenticationError: Request had invalid authentication credentials" in CI when run with other tests Test makes real API calls in CI without this fix, gets 401 error. Locally fails with "No module named 'vertexai'" (expected). Related: test was failing on PR #21217, but NOT caused by PR #21217 (which only modifies test_anthropic_structured_output.py). This is another test isolation issue. Co-Authored-By: Claude Sonnet 4.5 --- .../test_vertex_ai_gpt_oss_transformation.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/gpt_oss/test_vertex_ai_gpt_oss_transformation.py b/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/gpt_oss/test_vertex_ai_gpt_oss_transformation.py index 34046a00ee8..7e7d16bbc0a 100644 --- a/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/gpt_oss/test_vertex_ai_gpt_oss_transformation.py +++ b/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/gpt_oss/test_vertex_ai_gpt_oss_transformation.py @@ -16,6 +16,30 @@ ) +@pytest.fixture(autouse=True) +def clean_vertex_env(): + """Clear Google/Vertex AI environment variables before each test to prevent test isolation issues.""" + saved_env = {} + env_vars_to_clear = [ + "GOOGLE_APPLICATION_CREDENTIALS", + "GOOGLE_CLOUD_PROJECT", + "VERTEXAI_PROJECT", + "VERTEX_PROJECT", + "VERTEX_LOCATION", + "VERTEX_AI_PROJECT", + ] + for var in env_vars_to_clear: + if var in os.environ: + saved_env[var] = os.environ[var] + del os.environ[var] + + yield + + # Restore saved environment variables + for var, value in saved_env.items(): + os.environ[var] = value + + class TestVertexAIGPTOSSTransformation: """Test class for VertexAI GPT-OSS transformation functionality.""" From cdb0b6b9dcfce1f7efbab70c1a3a121d601ab160 Mon Sep 17 00:00:00 2001 From: jquinter Date: Sun, 15 Feb 2026 19:25:35 -0300 Subject: [PATCH 2/2] Update tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/gpt_oss/test_vertex_ai_gpt_oss_transformation.py Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- .../gpt_oss/test_vertex_ai_gpt_oss_transformation.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/gpt_oss/test_vertex_ai_gpt_oss_transformation.py b/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/gpt_oss/test_vertex_ai_gpt_oss_transformation.py index 7e7d16bbc0a..df1fe26df8b 100644 --- a/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/gpt_oss/test_vertex_ai_gpt_oss_transformation.py +++ b/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/gpt_oss/test_vertex_ai_gpt_oss_transformation.py @@ -24,6 +24,8 @@ def clean_vertex_env(): "GOOGLE_APPLICATION_CREDENTIALS", "GOOGLE_CLOUD_PROJECT", "VERTEXAI_PROJECT", + "VERTEXAI_LOCATION", + "VERTEXAI_CREDENTIALS", "VERTEX_PROJECT", "VERTEX_LOCATION", "VERTEX_AI_PROJECT",