@@ -264,7 +264,7 @@ def test_register_fault_embedding():
264264 with open (file_path , "w" ) as f :
265265 json .dump (data , f , indent = 4 )
266266
267- # Debug: Verify file was created
267+ # Debug: Verify file was created
268268 print (f"DEBUG: File exists after writing: { os .path .exists (file_path )} " )
269269 if os .path .exists (file_path ):
270270 with open (file_path , "r" ) as f :
@@ -302,8 +302,10 @@ def custom_warning_handler(
302302 # Restore original warning handler
303303 warnings .showwarning = old_showwarning
304304
305- # Now run with pytest.warns to capture the official warningswith pytest.warns(UserWarning) as record:
305+ # Now run with pytest.warns to capture the official warnings
306+ with pytest .warns (UserWarning ) as record :
306307 _install ()
308+
307309 print (f"DEBUG: pytest.warns captured { len (record )} warnings" )
308310 for i , warning in enumerate (record ):
309311 print (f"DEBUG: pytest warning { i + 1 } : { warning .message } " )
@@ -317,8 +319,8 @@ def custom_warning_handler(
317319 print (f"DEBUG: Checking warning message: { message } " )
318320 if (
319321 "has error" in message
320- and (
321- "Invalid model URI " in message
322+ and (
323+ "Invalid model URI" in message
322324 or "Model URI cannot be a relative path" in message
323325 )
324326 and "/new_data/cache/gte-Qwen2" in message
@@ -329,9 +331,9 @@ def custom_warning_handler(
329331
330332 assert (
331333 found_warning
332- ), f"Expected warning about invalid model URI not found. Warnings: { [str (w .message )
333- for w in record ] } "
334- finally :
334+ ), f"Expected warning about invalid model URI not found. Warnings: { [str (w .message ) for w in record ] } "
335+
336+ finally :
335337 # Restore original warning handler
336338 warnings .showwarning = old_showwarning
337339
@@ -342,10 +344,6 @@ def custom_warning_handler(
342344 if os .path .exists (file_path ):
343345 os .remove (file_path )
344346 print ("DEBUG: Test file cleaned up" )
345- finally :
346- # Clean up the test file to avoid interference with subsequent test runs
347- if os .path .exists (file_path ):
348- os .remove (file_path )
349347
350348
351349def test_convert_ids_to_tokens ():
0 commit comments