File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-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 1010import pathlib
1111import platform
1212import stat
13+ import tempfile
1314import unittest
1415
1516import pandas as pd
1617
18+ import khiops .core .internals .filesystems as fs
1719from khiops .core .dictionary import DictionaryDomain
1820from khiops .core .helpers import _build_multi_table_dictionary_domain , visualize_report
1921from khiops .sklearn import train_test_split_dataset
@@ -473,3 +475,20 @@ def test_visualize_report_fails_on_file_with_executable_permissions(self):
4734757,4,16.66.64.13
4744767,4,15.13.69.18
475477""" .lstrip ()
478+
479+
480+ class LocalFileSystemTests (unittest .TestCase ):
481+
482+ def setUp (self ):
483+ self .current_dir = os .getcwd () # save the current directory
484+
485+ def test_copy_from_local_for_a_relative_target_path (self ):
486+ """Test fs.copy_from_local for the specific case where the target file has a relative path"""
487+ tmp_file_fd , tmp_file_path = tempfile .mkstemp (prefix = 'khiops-python-unit-test' , dir = '/tmp/' )
488+ os .close (tmp_file_fd )
489+ os .chdir ('/tmp' ) # folder location of the target file
490+ fs .copy_from_local ('khiops-python-unit-test-target1.txt' , tmp_file_path )
491+ fs .copy_from_local ('./khiops-python-unit-test-target2.txt' , tmp_file_path )
492+
493+ def tearDown (self ):
494+ os .chdir (self .current_dir ) # restore the current directory
You can’t perform that action at this time.
0 commit comments