diff --git a/google/genai/tests/pytest_helper.py b/google/genai/tests/pytest_helper.py index 17076cd82..f22f1e8bb 100644 --- a/google/genai/tests/pytest_helper.py +++ b/google/genai/tests/pytest_helper.py @@ -79,6 +79,13 @@ def base_test_function( assert False, 'Should have raised exception in Vertex.' client._api_client.close() except Exception as e: + # Gracefully skip the test if we hit a live API quota limit + if getattr(e, 'code', None) == 429 and getattr(client._api_client, '_mode', None) == 'api': + pytest.skip( + 'Resource Exhausted (429). Skipping test instead of' + f' failing: {e}' + ) + if test_table_item.exception_if_mldev and not client._api_client.vertexai: if test_table_item.exception_if_mldev not in str(e): raise AssertionError( diff --git a/google/genai/tests/shared/models/test_generate_videos.py b/google/genai/tests/shared/models/test_generate_videos.py index e2ae85fba..73c789884 100644 --- a/google/genai/tests/shared/models/test_generate_videos.py +++ b/google/genai/tests/shared/models/test_generate_videos.py @@ -28,6 +28,15 @@ parameters=types._GenerateVideosParameters( model=VEO_MODEL_LATEST_VERTEX, prompt="Man with a dog", + config=types.GenerateVideosConfig( + http_options=types.HttpOptions( + retry_options=types.HttpRetryOptions( + attempts=2, + initial_delay=10.0, + http_status_codes=[429, 500, 502, 503, 504], + ), + ), + ), ), exception_if_mldev=( "models/veo-3.1-lite-generate-001 is not found for API version v1beta" @@ -38,6 +47,15 @@ parameters=types._GenerateVideosParameters( model=VEO_MODEL_LATEST_GEMINI, prompt="Man with a dog", + config=types.GenerateVideosConfig( + http_options=types.HttpOptions( + retry_options=types.HttpRetryOptions( + attempts=2, + initial_delay=10.0, + http_status_codes=[429, 500, 502, 503, 504], + ), + ), + ), ), exception_if_vertex=( "404 NOT_FOUND"