Skip to content

Commit cd1e683

Browse files
committed
fix tests after cli adjustments
1 parent 48094d2 commit cd1e683

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

tests/models/test_cohere.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,5 +543,5 @@ async def test_cohere_model_thinking_part(allow_model_requests: None, co_api_key
543543
async def test_cohere_model_builtin_tools(allow_model_requests: None, co_api_key: str):
544544
m = CohereModel('command-r7b-12-2024', provider=CohereProvider(api_key=co_api_key))
545545
agent = Agent(m, builtin_tools=[WebSearchTool()])
546-
with pytest.raises(UserError, match='Builtin tool WebSearchTool is not supported by this model'):
546+
with pytest.raises(UserError, match=r"Builtin tool\(s\) \['WebSearchTool'\] not supported by this model"):
547547
await agent.run('Hello')

tests/models/test_openai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2301,7 +2301,7 @@ async def test_openai_web_search_tool_model_not_supported(allow_model_requests:
23012301
m, instructions='You are a helpful assistant.', builtin_tools=[WebSearchTool(search_context_size='low')]
23022302
)
23032303

2304-
with pytest.raises(UserError, match='Builtin tool WebSearchTool is not supported by this model'):
2304+
with pytest.raises(UserError, match=r"Builtin tool\(s\) \['WebSearchTool'\] not supported by this model"):
23052305
await agent.run('What day is today?')
23062306

23072307

tests/test_cli.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -380,13 +380,13 @@ def test_clai_web_generic_agent(mocker: MockerFixture, env: TestEnv):
380380
env.set('OPENAI_API_KEY', 'test')
381381
mock_run_web = mocker.patch('pydantic_ai._cli.web.run_web_command', return_value=0)
382382

383-
assert cli(['web', '-m', 'gpt-5', '-t', 'web_search'], prog_name='clai') == 0
383+
assert cli(['web', '-m', 'openai:gpt-5', '-t', 'web_search'], prog_name='clai') == 0
384384

385385
mock_run_web.assert_called_once_with(
386386
agent_path=None,
387387
host='127.0.0.1',
388388
port=7932,
389-
models=['gpt-5'],
389+
models=['openai:gpt-5'],
390390
tools=['web_search'],
391391
instructions=None,
392392
mcp=None,
@@ -424,15 +424,26 @@ def test_clai_web_with_models(mocker: MockerFixture, create_test_module: Callabl
424424
create_test_module(custom_agent=test_agent)
425425

426426
assert (
427-
cli(['web', '--agent', 'test_module:custom_agent', '-m', 'gpt-5', '-m', 'claude-sonnet-4-5'], prog_name='clai')
427+
cli(
428+
[
429+
'web',
430+
'--agent',
431+
'test_module:custom_agent',
432+
'-m',
433+
'openai:gpt-5',
434+
'-m',
435+
'anthropic:claude-sonnet-4-5',
436+
],
437+
prog_name='clai',
438+
)
428439
== 0
429440
)
430441

431442
mock_run_web.assert_called_once_with(
432443
agent_path='test_module:custom_agent',
433444
host='127.0.0.1',
434445
port=7932,
435-
models=['gpt-5', 'claude-sonnet-4-5'],
446+
models=['openai:gpt-5', 'anthropic:claude-sonnet-4-5'],
436447
tools=None,
437448
instructions=None,
438449
mcp=None,
@@ -472,13 +483,13 @@ def test_clai_web_generic_with_instructions(mocker: MockerFixture, env: TestEnv)
472483

473484
mock_run_web = mocker.patch('pydantic_ai._cli.web.run_web_command', return_value=0)
474485

475-
assert cli(['web', '-m', 'gpt-5', '-i', 'You are a helpful coding assistant'], prog_name='clai') == 0
486+
assert cli(['web', '-m', 'openai:gpt-5', '-i', 'You are a helpful coding assistant'], prog_name='clai') == 0
476487

477488
mock_run_web.assert_called_once_with(
478489
agent_path=None,
479490
host='127.0.0.1',
480491
port=7932,
481-
models=['gpt-5'],
492+
models=['openai:gpt-5'],
482493
tools=None,
483494
instructions='You are a helpful coding assistant',
484495
mcp=None,

0 commit comments

Comments
 (0)