Skip to content

Commit cf3b691

Browse files
committed
Revert "try to fix coverage"
This reverts commit 909cabd.
1 parent b4fa954 commit cf3b691

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

tests/test_cli.py

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,13 @@ def _create_test_module(**namespace: Any) -> None:
5858

5959

6060
@pytest.fixture
61-
def create_last_conversation_file():
61+
def emtpy_last_conversation_path():
6262
path = PYDANTIC_AI_HOME / LAST_CONVERSATION_FILENAME
6363

64-
def _factory(empty: bool = True) -> Path:
65-
if empty and path.exists():
66-
path.unlink()
64+
if path.exists():
65+
path.unlink()
6766

68-
return path
69-
70-
return _factory
67+
return path
7168

7269

7370
def test_agent_flag(
@@ -182,36 +179,32 @@ def test_cli_continue_last_conversation(
182179
args: list[str],
183180
capfd: CaptureFixture[str],
184181
env: TestEnv,
185-
create_last_conversation_file: Callable[..., Path],
182+
emtpy_last_conversation_path: Path,
186183
):
187-
last_conversation_path = create_last_conversation_file()
188-
189184
env.set('OPENAI_API_KEY', 'test')
190185
with cli_agent.override(model=TestModel(custom_output_text='# world')):
191186
assert cli(args) == 0
192187
assert capfd.readouterr().out.splitlines() == snapshot([IsStr(), '# world'])
193-
assert last_conversation_path.exists()
194-
content = last_conversation_path.read_text()
188+
assert emtpy_last_conversation_path.exists()
189+
content = emtpy_last_conversation_path.read_text()
195190
assert content
196191

197192
assert cli(args) == 0
198193
assert capfd.readouterr().out.splitlines() == snapshot([IsStr(), '# world'])
199-
assert last_conversation_path.exists()
194+
assert emtpy_last_conversation_path.exists()
200195
# verity that new content is appended to the file
201-
assert len(last_conversation_path.read_text()) > len(content)
196+
assert len(emtpy_last_conversation_path.read_text()) > len(content)
202197

203198

204199
@pytest.mark.parametrize('args', [['hello', '-c'], ['hello', '--continue']])
205200
def test_cli_continue_last_conversation_corrupted_file(
206201
args: list[str],
207202
capfd: CaptureFixture[str],
208203
env: TestEnv,
209-
create_last_conversation_file: Callable[..., Path],
204+
emtpy_last_conversation_path: Path,
210205
):
211-
last_conversation_path = create_last_conversation_file()
212-
213206
env.set('OPENAI_API_KEY', 'test')
214-
last_conversation_path.write_text('not a valid json')
207+
emtpy_last_conversation_path.write_text('not a valid json')
215208
with cli_agent.override(model=TestModel(custom_output_text='# world')):
216209
assert cli(args) == 0
217210
assert capfd.readouterr().out.splitlines() == snapshot(
@@ -222,8 +215,8 @@ def test_cli_continue_last_conversation_corrupted_file(
222215
'# world',
223216
]
224217
)
225-
assert last_conversation_path.exists()
226-
assert last_conversation_path.read_text()
218+
assert emtpy_last_conversation_path.exists()
219+
assert emtpy_last_conversation_path.read_text()
227220

228221

229222
def test_chat(capfd: CaptureFixture[str], mocker: MockerFixture, env: TestEnv):

0 commit comments

Comments
 (0)