MCPcopy
hub / github.com/openai/openai-agents-python / test_run_demo_loop_conversation

Function test_run_demo_loop_conversation

tests/test_repl.py:16–34  ·  view source on GitHub ↗
(monkeypatch, capsys)

Source from the content-addressed store, hash-verified

14
15@pytest.mark.asyncio
16async def test_run_demo_loop_conversation(monkeypatch, capsys):
17 model = FakeModel()
18 model.add_multiple_turn_outputs([[get_text_message("hello")], [get_text_message("good")]])
19
20 agent = Agent(name="test", model=model)
21
22 inputs = iter(["Hi", "How are you?", "quit"])
23 monkeypatch.setattr("builtins.input", lambda _=" > ": next(inputs))
24
25 await run_demo_loop(agent, stream=False)
26
27 output = capsys.readouterr().out
28 assert "hello" in output
29 assert "good" in output
30 assert model.last_turn_args["input"] == [
31 get_text_input_item("Hi"),
32 get_text_message("hello").model_dump(exclude_unset=True),
33 get_text_input_item("How are you?"),
34 ]
35
36
37@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 7

AgentClass · 0.90
run_demo_loopFunction · 0.90
FakeModelClass · 0.85
get_text_messageFunction · 0.85
get_text_input_itemFunction · 0.85
model_dumpMethod · 0.45

Tested by

no test coverage detected