Skip to content

Commit b8b3e6f

Browse files
committed
fix: test discovery and coverage run
Fix test discovery by ignoring the new Test prefixed classes in the the test model package. Disable the warning about conflicting includes for pytest coverage, allowing VS Code to run its pytest coverage command successfully.
1 parent 5bdf9bb commit b8b3e6f

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

pydantic_ai_slim/pydantic_ai/models/test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ class _WrappedToolOutput:
4949
class TestToolCallPart:
5050
"""Represents a tool call in the test model."""
5151

52+
# NOTE: Avoid test discovery by pytest.
53+
__test__ = False
54+
5255
call_tools: list[str] | Literal['all'] = 'all'
5356
deltas: bool = False
5457

@@ -57,6 +60,9 @@ class TestToolCallPart:
5760
class TestTextPart:
5861
"""Represents a text part in the test model."""
5962

63+
# NOTE: Avoid test discovery by pytest.
64+
__test__ = False
65+
6066
text: str
6167

6268

@@ -68,6 +74,9 @@ class TestTextPart:
6874
class TestNode:
6975
"""A node in the test model."""
7076

77+
# NOTE: Avoid test discovery by pytest.
78+
__test__ = False
79+
7180
parts: list[TestPart]
7281
id: str = field(default_factory=_utils.generate_tool_call_id)
7382

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ filterwarnings = [
205205
# random resource warnings; I suspect these are coming from vendor SDKs when running examples..
206206
"ignore:unclosed <socket:ResourceWarning",
207207
"ignore:unclosed event loop:ResourceWarning",
208+
# Allow pytest coverage to run without erroring.
209+
"ignore:--include is ignored because --source is set:",
208210
]
209211

210212
# https://coverage.readthedocs.io/en/latest/config.html#run

0 commit comments

Comments
 (0)