@@ -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
7370def  test_agent_flag (
@@ -181,36 +178,32 @@ def test_cli_continue_last_conversation(
181178    args : list [str ],
182179    capfd : CaptureFixture [str ],
183180    env : TestEnv ,
184-     create_last_conversation_file :  Callable [...,  Path ] ,
181+     emtpy_last_conversation_path :  Path ,
185182):
186-     last_conversation_path  =  create_last_conversation_file ()
187- 
188183    env .set ('OPENAI_API_KEY' , 'test' )
189184    with  cli_agent .override (model = TestModel (custom_output_text = '# world' )):
190185        assert  cli (args ) ==  0 
191186        assert  capfd .readouterr ().out .splitlines () ==  snapshot ([IsStr (), '# world' ])
192-         assert  last_conversation_path .exists ()
193-         content  =  last_conversation_path .read_text ()
187+         assert  emtpy_last_conversation_path .exists ()
188+         content  =  emtpy_last_conversation_path .read_text ()
194189        assert  content 
195190
196191        assert  cli (args ) ==  0 
197192        assert  capfd .readouterr ().out .splitlines () ==  snapshot ([IsStr (), '# world' ])
198-         assert  last_conversation_path .exists ()
193+         assert  emtpy_last_conversation_path .exists ()
199194        # verity that new content is appended to the file 
200-         assert  len (last_conversation_path .read_text ()) >  len (content )
195+         assert  len (emtpy_last_conversation_path .read_text ()) >  len (content )
201196
202197
203198@pytest .mark .parametrize ('args' , [['hello' , '-c' ], ['hello' , '--continue' ]]) 
204199def  test_cli_continue_last_conversation_corrupted_file (
205200    args : list [str ],
206201    capfd : CaptureFixture [str ],
207202    env : TestEnv ,
208-     create_last_conversation_file :  Callable [...,  Path ] ,
203+     emtpy_last_conversation_path :  Path ,
209204):
210-     last_conversation_path  =  create_last_conversation_file ()
211- 
212205    env .set ('OPENAI_API_KEY' , 'test' )
213-     last_conversation_path .write_text ('not a valid json' )
206+     emtpy_last_conversation_path .write_text ('not a valid json' )
214207    with  cli_agent .override (model = TestModel (custom_output_text = '# world' )):
215208        assert  cli (args ) ==  0 
216209        assert  capfd .readouterr ().out .splitlines () ==  snapshot (
@@ -221,8 +214,8 @@ def test_cli_continue_last_conversation_corrupted_file(
221214                '# world' ,
222215            ]
223216        )
224-         assert  last_conversation_path .exists ()
225-         assert  last_conversation_path .read_text ()
217+         assert  emtpy_last_conversation_path .exists ()
218+         assert  emtpy_last_conversation_path .read_text ()
226219
227220
228221def  test_chat (capfd : CaptureFixture [str ], mocker : MockerFixture , env : TestEnv ):
0 commit comments