Skip to content

Commit 0969e0a

Browse files
committed
fix tests
1 parent e397836 commit 0969e0a

File tree

9 files changed

+88
-2
lines changed

9 files changed

+88
-2
lines changed

pydantic_ai_slim/pydantic_ai/agent/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def __init__(
245245
instrument: InstrumentationSettings | bool | None = None,
246246
history_processors: Sequence[HistoryProcessor[AgentDepsT]] | None = None,
247247
event_stream_handler: EventStreamHandler[AgentDepsT] | None = None,
248-
ignore_warning_cost: bool = False,
248+
ignore_warning_cost: bool = True,
249249
**_deprecated_kwargs: Any,
250250
):
251251
"""Create an agent.

tests/models/test_fallback.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def test_first_successful() -> None:
6868
usage=RequestUsage(input_tokens=51, output_tokens=1),
6969
model_name='function:success_response:',
7070
timestamp=IsNow(tz=timezone.utc),
71+
provider_name='function',
7172
),
7273
]
7374
)
@@ -93,6 +94,7 @@ def test_first_failed() -> None:
9394
usage=RequestUsage(input_tokens=51, output_tokens=1),
9495
model_name='function:success_response:',
9596
timestamp=IsNow(tz=timezone.utc),
97+
provider_name='function',
9698
),
9799
]
98100
)
@@ -119,6 +121,7 @@ def test_first_failed_instrumented(capfire: CaptureLogfire) -> None:
119121
usage=RequestUsage(input_tokens=51, output_tokens=1),
120122
model_name='function:success_response:',
121123
timestamp=IsNow(tz=timezone.utc),
124+
provider_name='function',
122125
),
123126
]
124127
)
@@ -204,18 +207,21 @@ async def test_first_failed_instrumented_stream(capfire: CaptureLogfire) -> None
204207
usage=RequestUsage(input_tokens=50, output_tokens=1),
205208
model_name='function::success_response_stream',
206209
timestamp=IsNow(tz=timezone.utc),
210+
provider_name='function',
207211
),
208212
ModelResponse(
209213
parts=[TextPart(content='hello world')],
210214
usage=RequestUsage(input_tokens=50, output_tokens=2),
211215
model_name='function::success_response_stream',
212216
timestamp=IsNow(tz=timezone.utc),
217+
provider_name='function',
213218
),
214219
ModelResponse(
215220
parts=[TextPart(content='hello world')],
216221
usage=RequestUsage(input_tokens=50, output_tokens=2),
217222
model_name='function::success_response_stream',
218223
timestamp=IsNow(tz=timezone.utc),
224+
provider_name='function',
219225
),
220226
]
221227
)
@@ -431,18 +437,21 @@ async def test_first_success_streaming() -> None:
431437
usage=RequestUsage(input_tokens=50, output_tokens=1),
432438
model_name='function::success_response_stream',
433439
timestamp=IsNow(tz=timezone.utc),
440+
provider_name='function',
434441
),
435442
ModelResponse(
436443
parts=[TextPart(content='hello world')],
437444
usage=RequestUsage(input_tokens=50, output_tokens=2),
438445
model_name='function::success_response_stream',
439446
timestamp=IsNow(tz=timezone.utc),
447+
provider_name='function',
440448
),
441449
ModelResponse(
442450
parts=[TextPart(content='hello world')],
443451
usage=RequestUsage(input_tokens=50, output_tokens=2),
444452
model_name='function::success_response_stream',
445453
timestamp=IsNow(tz=timezone.utc),
454+
provider_name='function',
446455
),
447456
]
448457
)
@@ -460,18 +469,21 @@ async def test_first_failed_streaming() -> None:
460469
usage=RequestUsage(input_tokens=50, output_tokens=1),
461470
model_name='function::success_response_stream',
462471
timestamp=IsNow(tz=timezone.utc),
472+
provider_name='function',
463473
),
464474
ModelResponse(
465475
parts=[TextPart(content='hello world')],
466476
usage=RequestUsage(input_tokens=50, output_tokens=2),
467477
model_name='function::success_response_stream',
468478
timestamp=IsNow(tz=timezone.utc),
479+
provider_name='function',
469480
),
470481
ModelResponse(
471482
parts=[TextPart(content='hello world')],
472483
usage=RequestUsage(input_tokens=50, output_tokens=2),
473484
model_name='function::success_response_stream',
474485
timestamp=IsNow(tz=timezone.utc),
486+
provider_name='function',
475487
),
476488
]
477489
)

tests/models/test_model_function.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def test_simple():
7070
usage=RequestUsage(input_tokens=51, output_tokens=3),
7171
model_name='function:return_last:',
7272
timestamp=IsNow(tz=timezone.utc),
73+
provider_name='function',
7374
),
7475
]
7576
)
@@ -84,13 +85,15 @@ def test_simple():
8485
usage=RequestUsage(input_tokens=51, output_tokens=3),
8586
model_name='function:return_last:',
8687
timestamp=IsNow(tz=timezone.utc),
88+
provider_name='function',
8789
),
8890
ModelRequest(parts=[UserPromptPart(content='World', timestamp=IsNow(tz=timezone.utc))]),
8991
ModelResponse(
9092
parts=[TextPart(content="content='World' part_kind='user-prompt' message_count=3")],
9193
usage=RequestUsage(input_tokens=52, output_tokens=6),
9294
model_name='function:return_last:',
9395
timestamp=IsNow(tz=timezone.utc),
96+
provider_name='function',
9497
),
9598
]
9699
)
@@ -161,6 +164,7 @@ def test_weather():
161164
usage=RequestUsage(input_tokens=51, output_tokens=5),
162165
model_name='function:weather_model:',
163166
timestamp=IsNow(tz=timezone.utc),
167+
provider_name='function',
164168
),
165169
ModelRequest(
166170
parts=[
@@ -177,6 +181,7 @@ def test_weather():
177181
usage=RequestUsage(input_tokens=56, output_tokens=11),
178182
model_name='function:weather_model:',
179183
timestamp=IsNow(tz=timezone.utc),
184+
provider_name='function',
180185
),
181186
ModelRequest(
182187
parts=[
@@ -193,6 +198,7 @@ def test_weather():
193198
usage=RequestUsage(input_tokens=57, output_tokens=14),
194199
model_name='function:weather_model:',
195200
timestamp=IsNow(tz=timezone.utc),
201+
provider_name='function',
196202
),
197203
]
198204
)
@@ -455,6 +461,7 @@ async def test_stream_text():
455461
usage=RequestUsage(input_tokens=50, output_tokens=2),
456462
model_name='function::stream_text_function',
457463
timestamp=IsNow(tz=timezone.utc),
464+
provider_name='function',
458465
),
459466
]
460467
)

tests/models/test_openai_responses.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,6 @@ async def test_openai_responses_usage_without_tokens_details(allow_model_request
11251125

11261126
assert result.usage() == snapshot(
11271127
RunUsage(
1128-
input_tokens=14, output_tokens=9, details={'reasoning_tokens': 0}, requests=1, cost=Decimal('0.000125')
1128+
input_tokens=14, output_tokens=1, details={'reasoning_tokens': 0}, requests=1, cost=Decimal('0.000045')
11291129
)
11301130
)

tests/test_a2a.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,7 @@ def track_messages(messages: list[ModelMessage], info: AgentInfo) -> ModelRespon
615615
usage=RequestUsage(input_tokens=52, output_tokens=7),
616616
model_name='function:track_messages:',
617617
timestamp=IsDatetime(),
618+
provider_name='function',
618619
),
619620
ModelRequest(
620621
parts=[

0 commit comments

Comments
 (0)