@@ -1602,26 +1602,25 @@ def test_apply_patch(self):
16021602 def test_copy_file (self ):
16031603 """Test copy_file function."""
16041604 testdir = os .path .dirname (os .path .abspath (__file__ ))
1605- to_copy = os .path .join (testdir , 'easyconfigs' , 'test_ecs' , 't' , 'toy' , 'toy-0.0.eb' )
1605+ toy_ec = os .path .join (testdir , 'easyconfigs' , 'test_ecs' , 't' , 'toy' , 'toy-0.0.eb' )
16061606 target_path = os .path .join (self .test_prefix , 'toy.eb' )
1607- ft .copy_file (to_copy , target_path )
1607+ ft .copy_file (toy_ec , target_path )
16081608 self .assertTrue (os .path .exists (target_path ))
1609- self .assertTrue (ft .read_file (to_copy ) == ft .read_file (target_path ))
1609+ self .assertTrue (ft .read_file (toy_ec ) == ft .read_file (target_path ))
16101610
16111611 # Make sure it doesn't fail if path is a symlink and target_path is a dir
1612- link_to_copy = os .path .join (testdir , 'easyconfigs' , 'test_ecs' , 't' , 'toy' , 'toy-link-0.0.eb' )
1613- base_dir = os .path .join (testdir , 'easyconfigs' , 'test_ecs' , 't' , 'toy' )
1614- link_to_copy = 'toy-link-0.0.eb'
1615- dir_target_path = self .test_prefix
1616- ft .copy_file (os .path .join (base_dir , link_to_copy ), dir_target_path )
1617- self .assertTrue (os .path .islink (os .path .join (dir_target_path , link_to_copy )))
1618- link_source = os .readlink (os .path .join (base_dir , link_to_copy ))
1619- link_target = os .readlink (os .path .join (dir_target_path , link_to_copy ))
1620- self .assertTrue (link_target == link_source )
1621- os .remove (os .path .join (dir_target_path , link_to_copy ))
1612+ toy_link_fn = 'toy-link-0.0.eb'
1613+ toy_link = os .path .join (self .test_prefix , toy_link_fn )
1614+ ft .symlink (toy_ec , toy_link )
1615+ dir_target_path = os .path .join (self .test_prefix , 'subdir' )
1616+ ft .mkdir (dir_target_path )
1617+ ft .copy_file (toy_link , dir_target_path )
1618+ self .assertTrue (os .path .islink (os .path .join (dir_target_path , toy_link_fn )))
1619+ self .assertEqual (os .readlink (os .path .join (dir_target_path , toy_link_fn )), os .readlink (toy_link ))
1620+ os .remove (os .path .join (dir_target_path , toy_link ))
16221621
16231622 # clean error when trying to copy a directory with copy_file
1624- src , target = os .path .dirname (to_copy ), os .path .join (self .test_prefix , 'toy' )
1623+ src , target = os .path .dirname (toy_ec ), os .path .join (self .test_prefix , 'toy' )
16251624 # error message was changed in Python 3.9.7 to "FileNotFoundError: Directory does not exist"
16261625 error_pattern = "Failed to copy file.*(Is a directory|Directory does not exist)"
16271626 self .assertErrorRegex (EasyBuildError , error_pattern , ft .copy_file , src , target )
@@ -1658,7 +1657,7 @@ def test_copy_file(self):
16581657 os .remove (target_path )
16591658
16601659 self .mock_stdout (True )
1661- ft .copy_file (to_copy , target_path )
1660+ ft .copy_file (toy_ec , target_path )
16621661 txt = self .get_stdout ()
16631662 self .mock_stdout (False )
16641663
@@ -1667,12 +1666,12 @@ def test_copy_file(self):
16671666
16681667 # forced copy, even in dry run mode
16691668 self .mock_stdout (True )
1670- ft .copy_file (to_copy , target_path , force_in_dry_run = True )
1669+ ft .copy_file (toy_ec , target_path , force_in_dry_run = True )
16711670 txt = self .get_stdout ()
16721671 self .mock_stdout (False )
16731672
16741673 self .assertTrue (os .path .exists (target_path ))
1675- self .assertTrue (ft .read_file (to_copy ) == ft .read_file (target_path ))
1674+ self .assertTrue (ft .read_file (toy_ec ) == ft .read_file (target_path ))
16761675 self .assertEqual (txt , '' )
16771676
16781677 # Test that a non-existing file raises an exception
@@ -2205,7 +2204,7 @@ def test_index_functions(self):
22052204 # test with specified path with and without trailing '/'s
22062205 for path in [test_ecs , test_ecs + '/' , test_ecs + '//' ]:
22072206 index = ft .create_index (path )
2208- self .assertEqual (len (index ), 90 )
2207+ self .assertEqual (len (index ), 89 )
22092208
22102209 expected = [
22112210 os .path .join ('b' , 'bzip2' , 'bzip2-1.0.6-GCC-4.9.2.eb' ),
0 commit comments