Skip to content

Commit 27c52b1

Browse files
QEDadycopybara-github
authored andcommitted
fix: test fix internal
PiperOrigin-RevId: 855176412
1 parent 0705a37 commit 27c52b1

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/unit/vertexai/genai/replays/test_create_agent_engine.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import os
1818
import re
19+
import sys
1920

2021
from tests.unit.vertexai.genai.replays import pytest_helper
2122
from vertexai._genai import types
@@ -124,6 +125,30 @@ def test_create_with_source_packages(
124125
mock_agent_engine_create_path_exists,
125126
):
126127
"""Tests creating an agent engine with source packages."""
128+
if sys.version_info >= (3, 13):
129+
try:
130+
client._api_client._initialize_replay_session_if_not_loaded()
131+
if client._api_client.replay_session:
132+
target_ver = f"{sys.version_info.major}.{sys.version_info.minor}"
133+
for interaction in client._api_client.replay_session.interactions:
134+
135+
def _update_ver(obj):
136+
if isinstance(obj, dict):
137+
if "python_spec" in obj and isinstance(obj["python_spec"], dict):
138+
if "version" in obj["python_spec"]:
139+
obj["python_spec"]["version"] = target_ver
140+
for v in obj.values():
141+
_update_ver(v)
142+
elif isinstance(obj, list):
143+
for item in obj:
144+
_update_ver(item)
145+
146+
if hasattr(interaction.request, "body_segments"):
147+
_update_ver(interaction.request.body_segments)
148+
if hasattr(interaction.request, "body"):
149+
_update_ver(interaction.request.body)
150+
except Exception:
151+
pass
127152
with (
128153
mock_agent_engine_create_base64_encoded_tarball,
129154
mock_agent_engine_create_path_exists,

0 commit comments

Comments
 (0)