Skip to content

Commit 1dee214

Browse files
committed
chore(ag-ui): only run tests on python 3.10 and above
Limit ag-ui tests to run on Python 3.10 and above as it makes use of match statements which are not available in earlier versions.
1 parent 1b5fcac commit 1dee214

File tree

2 files changed

+35
-24
lines changed

2 files changed

+35
-24
lines changed

tests/adapter_ag_ui/test_adapter.py

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import asyncio
77
import contextlib
88
import re
9+
import sys
910
import uuid
1011
from collections.abc import Callable
1112
from dataclasses import dataclass, field
@@ -17,31 +18,37 @@
1718
from pydantic_ai import Agent
1819
from pydantic_ai.models.test import TestModel
1920

21+
has_required_python: bool = sys.version_info >= (3, 10)
2022
has_ag_ui: bool = False
21-
with contextlib.suppress(ImportError):
22-
from ag_ui.core import (
23-
AssistantMessage,
24-
CustomEvent,
25-
DeveloperMessage,
26-
EventType,
27-
FunctionCall,
28-
Message,
29-
RunAgentInput,
30-
StateSnapshotEvent,
31-
SystemMessage,
32-
Tool,
33-
ToolCall,
34-
ToolMessage,
35-
UserMessage,
36-
)
23+
if has_required_python:
24+
with contextlib.suppress(ImportError):
25+
from ag_ui.core import (
26+
AssistantMessage,
27+
CustomEvent,
28+
DeveloperMessage,
29+
EventType,
30+
FunctionCall,
31+
Message,
32+
RunAgentInput,
33+
StateSnapshotEvent,
34+
SystemMessage,
35+
Tool,
36+
ToolCall,
37+
ToolMessage,
38+
UserMessage,
39+
)
3740

38-
from adapter_ag_ui._enums import Role
39-
from adapter_ag_ui.adapter import AdapterAGUI
41+
from adapter_ag_ui._enums import Role
42+
from adapter_ag_ui.adapter import AdapterAGUI
4043

41-
has_ag_ui = True
44+
has_ag_ui = True
4245

4346

44-
pytestmark = [pytest.mark.anyio, pytest.mark.skipif(not has_ag_ui, reason='adapter-ag-ui not installed')]
47+
pytestmark = [
48+
pytest.mark.anyio,
49+
pytest.mark.skipif(not has_required_python, reason='requires Python 3.10 or higher'),
50+
pytest.mark.skipif(has_required_python and not has_ag_ui, reason='adapter-ag-ui not installed'),
51+
]
4552

4653
# Type aliases.
4754
_MockUUID = Callable[[], str]

tests/test_ag_ui.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import contextlib
66
import logging
7+
import sys
78
from dataclasses import dataclass, field
89
from typing import Final
910

@@ -12,16 +13,19 @@
1213
from pydantic_ai import Agent
1314
from pydantic_ai.models.test import TestModel
1415

16+
has_required_python: bool = sys.version_info >= (3, 10)
1517
has_ag_ui: bool = False
16-
with contextlib.suppress(ImportError):
17-
from adapter_ag_ui.adapter import _LOGGER as adapter_logger, AdapterAGUI # type: ignore[reportPrivateUsage]
18+
if has_required_python:
19+
with contextlib.suppress(ImportError):
20+
from adapter_ag_ui.adapter import _LOGGER as adapter_logger, AdapterAGUI # type: ignore[reportPrivateUsage]
1821

19-
has_ag_ui = True
22+
has_ag_ui = True
2023

2124

2225
pytestmark = [
2326
pytest.mark.anyio,
24-
pytest.mark.skipif(not has_ag_ui, reason='adapter-ag-ui not installed'),
27+
pytest.mark.skipif(not has_required_python, reason='requires Python 3.10 or higher'),
28+
pytest.mark.skipif(has_required_python and not has_ag_ui, reason='adapter-ag-ui not installed'),
2529
]
2630

2731
# Constants.

0 commit comments

Comments
 (0)