File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -418,7 +418,7 @@ def remove(paths):
418418 _log .info ("Removing %d files & directories" , len (paths ))
419419
420420 for path in paths :
421- if os .path .isfile (path ):
421+ if os .path .isfile (path ) or os . path . islink ( path ) :
422422 remove_file (path )
423423 elif os .path .isdir (path ):
424424 remove_dir (path )
Original file line number Diff line number Diff line change @@ -2555,12 +2555,24 @@ def test_remove(self):
25552555 """Test remove_file, remove_dir and join remove functions."""
25562556 testfile = os .path .join (self .test_prefix , 'foo' )
25572557 test_dir = os .path .join (self .test_prefix , 'test123' )
2558+ test_link = os .path .join (self .test_prefix , 'foolink' )
25582559
25592560 for remove_file_function in (ft .remove_file , ft .remove ):
25602561 ft .write_file (testfile , 'bar' )
25612562 self .assertExists (testfile )
2563+ # remove symlink
2564+ ft .symlink (testfile , test_link )
2565+ self .assertTrue (os .path .islink (test_link ))
2566+ remove_file_function (test_link )
2567+ self .assertNotExists (test_link )
2568+ # remove file
25622569 remove_file_function (testfile )
25632570 self .assertNotExists (testfile )
2571+ # remove broken symlink
2572+ ft .symlink (testfile , test_link )
2573+ self .assertTrue (os .path .islink (test_link ))
2574+ remove_file_function (test_link )
2575+ self .assertNotExists (test_link )
25642576
25652577 for remove_dir_function in (ft .remove_dir , ft .remove ):
25662578 ft .mkdir (test_dir )
You can’t perform that action at this time.
0 commit comments