@@ -366,7 +366,7 @@ def test_code_interpreter_run_with_files(mocker):
366366 response = interpreter .run (
367367 code = 'with open("test.txt") as f: print(f.read())' ,
368368 language = "python" ,
369- files = files_to_upload , # Pass the list of dictionaries directly
369+ files = files_to_upload , # Pass the list of dictionaries directly
370370 )
371371
372372 # Verify the response
@@ -394,13 +394,14 @@ def test_code_interpreter_run_with_files(mocker):
394394 "files" : expected_files_payload ,
395395 }
396396
397+
397398def test_code_interpreter_run_with_invalid_file_dict_structure (mocker ):
398399 """Test that run raises ValueError for missing keys in file dict."""
399400 client = mocker .MagicMock ()
400401 interpreter = CodeInterpreter (client )
401402
402403 invalid_files = [
403- {"name" : "test.txt" , "content" : "Missing encoding" } # Missing 'encoding'
404+ {"name" : "test.txt" , "content" : "Missing encoding" } # Missing 'encoding'
404405 ]
405406
406407 with pytest .raises (ValueError , match = "Invalid file input format" ):
@@ -410,13 +411,18 @@ def test_code_interpreter_run_with_invalid_file_dict_structure(mocker):
410411 files = invalid_files ,
411412 )
412413
414+
413415def test_code_interpreter_run_with_invalid_file_dict_encoding (mocker ):
414416 """Test that run raises ValueError for invalid encoding value."""
415417 client = mocker .MagicMock ()
416418 interpreter = CodeInterpreter (client )
417419
418420 invalid_files = [
419- {"name" : "test.txt" , "encoding" : "utf-8" , "content" : "Invalid encoding" } # Invalid 'encoding' value
421+ {
422+ "name" : "test.txt" ,
423+ "encoding" : "utf-8" ,
424+ "content" : "Invalid encoding" ,
425+ } # Invalid 'encoding' value
420426 ]
421427
422428 with pytest .raises (ValueError , match = "Invalid file input format" ):
@@ -426,17 +432,21 @@ def test_code_interpreter_run_with_invalid_file_dict_encoding(mocker):
426432 files = invalid_files ,
427433 )
428434
435+
429436def test_code_interpreter_run_with_invalid_file_list_item (mocker ):
430437 """Test that run raises ValueError for non-dict item in files list."""
431438 client = mocker .MagicMock ()
432439 interpreter = CodeInterpreter (client )
433440
434441 invalid_files = [
435442 {"name" : "good.txt" , "encoding" : "string" , "content" : "Good" },
436- "not a dictionary" # Invalid item type
443+ "not a dictionary" , # Invalid item type
437444 ]
438445
439- with pytest .raises (ValueError , match = "Invalid file input: Each item in 'files' must be a dictionary" ):
446+ with pytest .raises (
447+ ValueError ,
448+ match = "Invalid file input: Each item in 'files' must be a dictionary" ,
449+ ):
440450 interpreter .run (
441451 code = "print('test')" ,
442452 language = "python" ,
0 commit comments