@@ -2705,6 +2705,29 @@ def test_link_count1(self):
2705
2705
self .os .unlink (file1_path )
2706
2706
self .assertEqual (self .os .stat (file2_path ).st_nlink , 1 )
2707
2707
2708
+ @unittest .skipIf (IS_PYPY , "follow_symlinks not supported in PyPi" )
2709
+ def test_link_no_follow_symlink (self ):
2710
+ self .skip_if_symlink_not_supported ()
2711
+ target_path = self .make_path ("target_path" )
2712
+ self .create_file (target_path , contents = "foo" )
2713
+ symlink_path = self .make_path ("symlink_to_file" )
2714
+ self .create_symlink (symlink_path , target_path )
2715
+ link_path = self .make_path ("link_to_symlink" )
2716
+ self .os .link (symlink_path , link_path , follow_symlinks = False )
2717
+ self .assertTrue (self .os .path .islink (link_path ))
2718
+
2719
+ @unittest .skipIf (not IS_PYPY , "follow_symlinks only not supported in PyPi" )
2720
+ def test_link_follow_symlink_not_supported_inPypy (self ):
2721
+ self .skip_if_symlink_not_supported ()
2722
+ target_path = self .make_path ("target_path" )
2723
+ self .create_file (target_path , contents = "foo" )
2724
+ symlink_path = self .make_path ("symlink_to_file" )
2725
+ self .create_symlink (symlink_path , target_path )
2726
+ link_path = self .make_path ("link_to_symlink" )
2727
+ with self .assertRaises (OSError ) as cm :
2728
+ self .os .link (symlink_path , link_path , follow_symlinks = False )
2729
+ self .assertEqual (errno .EINVAL , cm .exception .errno )
2730
+
2708
2731
def test_nlink_for_directories (self ):
2709
2732
self .skip_real_fs ()
2710
2733
self .create_dir (self .make_path ("foo" , "bar" ))
0 commit comments