File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -477,7 +477,7 @@ def remove(self):
477477
478478 def copy_from_local (self , local_path ):
479479 directory = os .path .dirname (self .path )
480- if not os .path .isdir (directory ):
480+ if len ( directory ) > 0 and not os .path .isdir (directory ):
481481 os .makedirs (directory )
482482 shutil .copy (local_path , self .path )
483483
Original file line number Diff line number Diff line change 2222
2323import khiops
2424import khiops .core as kh
25+ import khiops .core .internals .filesystems as fs
2526from khiops .core import KhiopsRuntimeError
2627from khiops .core .internals .io import KhiopsOutputWriter
2728from khiops .core .internals .runner import KhiopsLocalRunner , KhiopsRunner
@@ -3186,5 +3187,27 @@ def test_raise_exception_on_error_case_without_a_message(self):
31863187 self .assertEqual (output_msg , expected_msg )
31873188
31883189
3190+ class LocalFileSystemTests (unittest .TestCase ):
3191+ """Test the methods of the `LocalFileSystem`"""
3192+
3193+ def setUp (self ):
3194+ self .current_dir = os .getcwd () # save the current directory
3195+
3196+ def test_copy_from_local_for_a_relative_target_path (self ):
3197+ """Test fs.copy_from_local for the specific case
3198+ where the target file has a relative path
3199+ """
3200+ tmp_file_fd , tmp_file_path = tempfile .mkstemp (
3201+ prefix = "khiops-python-unit-test" , dir = "/tmp/"
3202+ )
3203+ os .close (tmp_file_fd )
3204+ os .chdir ("/tmp" ) # folder location of the target file
3205+ fs .copy_from_local ("khiops-python-unit-test-target1.txt" , tmp_file_path )
3206+ fs .copy_from_local ("./khiops-python-unit-test-target2.txt" , tmp_file_path )
3207+
3208+ def tearDown (self ):
3209+ os .chdir (self .current_dir ) # restore the current directory
3210+
3211+
31893212if __name__ == "__main__" :
31903213 unittest .main ()
You can’t perform that action at this time.
0 commit comments