File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed
Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -463,6 +463,9 @@ def read(self, size=None):
463463 return local_file .read (size )
464464
465465 def write (self , data ):
466+ directory = os .path .dirname (self .path )
467+ if len (directory ) > 0 and not os .path .isdir (directory ):
468+ os .makedirs (directory )
466469 with open (self .path , "wb" ) as output_file :
467470 output_file .write (data )
468471
Original file line number Diff line number Diff line change @@ -303,7 +303,11 @@ def test_dictionary(self):
303303 ref_kdic = os .path .join (ref_kdic_dir , f"{ dictionary } .kdic" )
304304 ref_kdicj = os .path .join (ref_kdicj_dir , f"{ dictionary } .kdicj" )
305305 output_kdic = os .path .join (output_kdic_dir , f"{ dictionary } .kdic" )
306+ output_kdic_in_a_new_folder = os .path .join (
307+ output_kdic_dir , "missing_folder" , f"{ dictionary } .kdic"
308+ )
306309 copy_output_kdic = os .path .join (copy_output_kdic_dir , f"{ dictionary } .kdic" )
310+
307311 with self .subTest (dictionary = dictionary ):
308312 if dictionary in dictionaries_warn :
309313 with self .assertWarns (UserWarning ):
@@ -312,6 +316,8 @@ def test_dictionary(self):
312316 domain = kh .read_dictionary_file (ref_kdicj )
313317 domain .export_khiops_dictionary_file (output_kdic )
314318 assert_files_equal (self , ref_kdic , output_kdic )
319+ domain .export_khiops_dictionary_file (output_kdic_in_a_new_folder )
320+ assert_files_equal (self , ref_kdic , output_kdic_in_a_new_folder )
315321
316322 domain_copy = domain .copy ()
317323 domain_copy .export_khiops_dictionary_file (copy_output_kdic )
You can’t perform that action at this time.
0 commit comments