mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
chore: Make UT of a2a consistent about how tests should be skipped when python verison < 3.10
PiperOrigin-RevId: 801040421
This commit is contained in:
committed by
Copybara-Service
parent
2eddc5e4d3
commit
98b0426cd2
@@ -49,34 +49,10 @@ try:
|
||||
from google.adk.events.event_actions import EventActions
|
||||
except ImportError as e:
|
||||
if sys.version_info < (3, 10):
|
||||
# Create dummy classes to prevent NameError during test collection
|
||||
# Tests will be skipped anyway due to pytestmark
|
||||
class DummyTypes:
|
||||
pass
|
||||
|
||||
DataPart = DummyTypes()
|
||||
Message = DummyTypes()
|
||||
Role = DummyTypes()
|
||||
Task = DummyTypes()
|
||||
TaskState = DummyTypes()
|
||||
TaskStatusUpdateEvent = DummyTypes()
|
||||
_create_artifact_id = lambda *args: None
|
||||
_create_error_status_event = lambda *args: None
|
||||
_create_status_update_event = lambda *args: None
|
||||
_get_adk_metadata_key = lambda *args: None
|
||||
_get_context_metadata = lambda *args: None
|
||||
_process_long_running_tool = lambda *args: None
|
||||
_serialize_metadata_value = lambda *args: None
|
||||
ADK_METADATA_KEY_PREFIX = "adk_"
|
||||
ARTIFACT_ID_SEPARATOR = "_"
|
||||
convert_event_to_a2a_events = lambda *args: None
|
||||
convert_event_to_a2a_message = lambda *args: None
|
||||
convert_a2a_task_to_event = lambda *args: None
|
||||
DEFAULT_ERROR_MESSAGE = "error"
|
||||
InvocationContext = DummyTypes()
|
||||
Event = DummyTypes()
|
||||
EventActions = DummyTypes()
|
||||
types = DummyTypes()
|
||||
# Imports are not needed since tests will be skipped due to pytestmark.
|
||||
# The imported names are only used within test methods, not at module level,
|
||||
# so no NameError occurs during module compilation.
|
||||
pass
|
||||
else:
|
||||
raise e
|
||||
|
||||
|
||||
@@ -38,21 +38,10 @@ try:
|
||||
from google.genai import types as genai_types
|
||||
except ImportError as e:
|
||||
if sys.version_info < (3, 10):
|
||||
# Create dummy classes to prevent NameError during test collection
|
||||
# Tests will be skipped anyway due to pytestmark
|
||||
class DummyTypes:
|
||||
pass
|
||||
|
||||
a2a_types = DummyTypes()
|
||||
genai_types = DummyTypes()
|
||||
A2A_DATA_PART_METADATA_TYPE_FUNCTION_CALL = "function_call"
|
||||
A2A_DATA_PART_METADATA_TYPE_FUNCTION_RESPONSE = "function_response"
|
||||
A2A_DATA_PART_METADATA_TYPE_CODE_EXECUTION_RESULT = "code_execution_result"
|
||||
A2A_DATA_PART_METADATA_TYPE_EXECUTABLE_CODE = "executable_code"
|
||||
A2A_DATA_PART_METADATA_TYPE_KEY = "type"
|
||||
convert_a2a_part_to_genai_part = lambda x: None
|
||||
convert_genai_part_to_a2a_part = lambda x: None
|
||||
_get_adk_metadata_key = lambda x: f"adk_{x}"
|
||||
# Imports are not needed since tests will be skipped due to pytestmark.
|
||||
# The imported names are only used within test methods, not at module level,
|
||||
# so no NameError occurs during module compilation.
|
||||
pass
|
||||
else:
|
||||
raise e
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import pytest
|
||||
|
||||
# Skip all tests in this module if Python version is less than 3.10
|
||||
pytestmark = pytest.mark.skipif(
|
||||
sys.version_info < (3, 10), reason="A2A tool requires Python 3.10+"
|
||||
sys.version_info < (3, 10), reason="A2A requires Python 3.10+"
|
||||
)
|
||||
|
||||
# Import dependencies with version checking
|
||||
@@ -32,17 +32,10 @@ try:
|
||||
from google.genai import types as genai_types
|
||||
except ImportError as e:
|
||||
if sys.version_info < (3, 10):
|
||||
# Create dummy classes to prevent NameError during test collection
|
||||
# Tests will be skipped anyway due to pytestmark
|
||||
class DummyTypes:
|
||||
pass
|
||||
|
||||
a2a_types = DummyTypes()
|
||||
genai_types = DummyTypes()
|
||||
RequestContext = DummyTypes()
|
||||
RunConfig = DummyTypes()
|
||||
_get_user_id = lambda x: None
|
||||
convert_a2a_request_to_adk_run_args = lambda x: None
|
||||
# Imports are not needed since tests will be skipped due to pytestmark.
|
||||
# The imported names are only used within test methods, not at module level,
|
||||
# so no NameError occurs during module compilation.
|
||||
pass
|
||||
else:
|
||||
raise e
|
||||
|
||||
|
||||
@@ -21,12 +21,21 @@ pytestmark = pytest.mark.skipif(
|
||||
sys.version_info < (3, 10), reason="A2A requires Python 3.10+"
|
||||
)
|
||||
|
||||
from google.adk.a2a.converters.utils import _from_a2a_context_id
|
||||
from google.adk.a2a.converters.utils import _get_adk_metadata_key
|
||||
from google.adk.a2a.converters.utils import _to_a2a_context_id
|
||||
from google.adk.a2a.converters.utils import ADK_CONTEXT_ID_PREFIX
|
||||
from google.adk.a2a.converters.utils import ADK_METADATA_KEY_PREFIX
|
||||
import pytest
|
||||
# Import dependencies with version checking
|
||||
try:
|
||||
from google.adk.a2a.converters.utils import _from_a2a_context_id
|
||||
from google.adk.a2a.converters.utils import _get_adk_metadata_key
|
||||
from google.adk.a2a.converters.utils import _to_a2a_context_id
|
||||
from google.adk.a2a.converters.utils import ADK_CONTEXT_ID_PREFIX
|
||||
from google.adk.a2a.converters.utils import ADK_METADATA_KEY_PREFIX
|
||||
except ImportError as e:
|
||||
if sys.version_info < (3, 10):
|
||||
# Imports are not needed since tests will be skipped due to pytestmark.
|
||||
# The imported names are only used within test methods, not at module level,
|
||||
# so no NameError occurs during module compilation.
|
||||
pass
|
||||
else:
|
||||
raise e
|
||||
|
||||
|
||||
class TestUtilsFunctions:
|
||||
|
||||
Reference in New Issue
Block a user