From 42f483c4c570ab4f98f168abc8477a4f00651255 Mon Sep 17 00:00:00 2001 From: Ayush Agrawal Date: Tue, 30 Jun 2026 11:35:31 -0700 Subject: [PATCH] chore: internal change PiperOrigin-RevId: 940568062 --- google/genai/tests/conftest.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/google/genai/tests/conftest.py b/google/genai/tests/conftest.py index 03b813631..4bec29727 100644 --- a/google/genai/tests/conftest.py +++ b/google/genai/tests/conftest.py @@ -55,6 +55,26 @@ def use_vertex(): return False +@pytest.fixture(autouse=True) +def skip_vertex_in_api_mode(request): + mode = request.config.getoption('--mode') + if mode == 'api' and not os.environ.get( + 'GOOGLE_GENAI_RUN_VERTEX_IN_API_MODE' + ): + if hasattr(request, 'node') and hasattr(request.node, 'callspec'): + if request.node.callspec.params.get('use_vertex') is True: + pytest.skip( + 'Skipping Vertex AI tests in API mode (no GCP credentials' + ' configured).' + ) + elif 'use_vertex' in request.fixturenames: + if request.getfixturevalue('use_vertex') is True: + pytest.skip( + 'Skipping Vertex AI tests in API mode (no GCP credentials' + ' configured).' + ) + + # Overridden at the module level for each test file. @pytest.fixture def replays_prefix():