Skip to content

Commit 020c8b8

Browse files
speedstorm1copybara-github
authored andcommitted
chore: internal
PiperOrigin-RevId: 956748348
1 parent 61d4645 commit 020c8b8

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

google/genai/tests/conftest.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,22 @@ def use_vertex():
5656

5757

5858
@pytest.fixture(autouse=True)
59-
def skip_vertex_in_api_mode(request):
59+
def skip_based_on_api_mode_env_vars(request):
6060
mode = request.config.getoption('--mode')
61-
if mode == 'api' and not os.environ.get(
62-
'GOOGLE_GENAI_RUN_VERTEX_IN_API_MODE'
63-
):
61+
if mode == 'api':
62+
use_vertex = None
6463
if hasattr(request, 'node') and hasattr(request.node, 'callspec'):
65-
if request.node.callspec.params.get('use_vertex') is True:
66-
pytest.skip(
67-
'Skipping Vertex AI tests in API mode (no GCP credentials'
68-
' configured).'
69-
)
64+
use_vertex = request.node.callspec.params.get('use_vertex')
7065
elif 'use_vertex' in request.fixturenames:
71-
if request.getfixturevalue('use_vertex') is True:
72-
pytest.skip(
73-
'Skipping Vertex AI tests in API mode (no GCP credentials'
74-
' configured).'
75-
)
66+
use_vertex = request.getfixturevalue('use_vertex')
67+
68+
run_vertex_only = os.environ.get('GOOGLE_GENAI_RUN_VERTEX_ONLY_IN_API_MODE')
69+
run_gemini_only = os.environ.get('GOOGLE_GENAI_RUN_GEMINI_ONLY_IN_API_MODE')
70+
71+
if use_vertex is True and run_gemini_only:
72+
pytest.skip('Skipping Vertex AI tests in API mode (GEMINI ONLY config enabled).')
73+
elif use_vertex is False and run_vertex_only:
74+
pytest.skip('Skipping Gemini API tests in API mode (VERTEX ONLY config enabled).')
7675

7776

7877
# Overridden at the module level for each test file.

0 commit comments

Comments
 (0)